Difference between src and require or include (path)

From any file on the website, if I want to call the image posted to / ico, I:

$arrow = "/ico/arrow.png";

      

without any ../ ico / ect. or. / ico / etc.

Now if I want to include the header.php file saved in / test:

<?php
include "/test/header.php";

      

or

require "/test/header.php";

      

or

require_once "/test/header.php";
?>

      

It won't work. I have to specify the path with ../ or. /.

I don't understand the difference!

Thank!

+3


source to share


1 answer


Image sources and hrefs links are evaluated by the client (browser). This means that they refer to:



Includes, on the other hand, evaluation by the server. This means that they refer to:

  • Filesystem root (if path starts with /

    )
  • The current working directory of the script (if the path does not start with /

    or starts with ./

    )
+3


source







All Articles