Might be an easy question for you, but I'm breaking my head over this one.
I have a php file that needs to know it's current directory url to be able to link to something relative to itself.
For example, currently I know to get the current directory path instead of the url. When I use this I get the path:
realpath(__DIR__)
result:
/Applications/MAMP/htdocs/mysite/dir1/dir2/dir3
But this would be my desired result:
http://localhost:8888/dir1/dir2/dir3
Note that this is not the location of the current page. The page calls a file from "http://localhost:8888/dir1/dir2/dir3/myfile.php" And "myfile.php" has the script from above.
-- edit to elaborate more details -- Thanks for your answers. But I get that I need to add more detail.
- http://localhost:8888/index.php calls: "http://localhost:8888/dir1/dir2/dir3/myfile.php"
- "myfile.php" needs to know it's place in the universe :) "Where am I"
- "myfile.php" should know it's url location is "http://localhost:8888/dir1/dir2/dir3/"