A bit weird question, but I ask because I want to know and understand. What is the difference between such records? How to write (according to scientific) a line?

header("Location:/user.php?uid=$uid"); header("Location: /user.php?uid=$uid"); header("Location:user.php?uid=$uid"); header("Location: user.php?uid=$uid"); 

    1 answer 1

    Between Location: and url it is better to put a space for greater readability. The difference between /user.php and user.php is that if there is a file at the beginning / the file will be searched in the project root, and if not, the folder in which the current script is located.

    • "The difference between /user.php and user.php is that if there is a file at the beginning / the file will be searched for in the project root, and if not, the folder in which the current script is located." - something I protupil about this. This is an absolute and relative path. - root_x Povierennyy
    • And it would be more correct to specify the full path header("Location: http://user.php?uid=$uid"); - Venta
    • @root_xPovierennyy Well, the absolute one starts from the root, and the relative one from the current url is lyhoshva
    • "specify the full path" - uh, but it can affect the portability of the code. Although I do not know. how it will work with httpS: // We have not yet studied working with certificates. - root_x Povierennyy
    • one
      @Venta "specify the full path" as for me is not the best idea. What will happen if you need to change the domain? Or, when copying to a local development computer, you will have to block the server ip with the local ip in /etc/hosts for the site to work. And as said @root_x Povierennyy if you need to go to https then on all such links you will need to change the protocol. - lyhoshva