suppose that I am working on a similar server PHP, with more projects, each of them with multiple subfolders and includes. Let's concentrate on proj1:
/var/www/html
/proj1
/inc
header.php
/assets
styles.css
script.js
page1.php
index.php
/proj2
...
Now, I want to include the css and the js with a relative path (not absolute) from header.php
, but if I use $_SERVER["DOCUMENT_ROOT"]
it returns to /var/www/html
.
What do you think it could be the better solution to echo "script.js"
in such scenario, without relying on absolute paths?
Thanks
PS: For the sake of clarity, we work on nested directories and structures, so I am searching for a way in which the relative path can change on these different folders, so it needs to be dynamic.