I have a php script that contains login and logout links that i want to use in my whole website. The intention is to have a variable that contains the URL that can be used through the entire site and never changes with the current page location
Using $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI'])
i get:
localhost/~MyName/MySite/current_folder
and it changes depending on the current location
Using __DIR__
i get:
/Users/MyName/Sites/MySite/php
Where "php" is the folder that contains the script
What i'm searching is:
localhost/~MyName/MySite/php
Where i'm in local, and:
https://www mysite com/php
Where i'm on the internet
I want the path to be stored in a variable and used in the script:
<?php
echo ("<a href= '$path . /logout.php'> Logout </a>");
?>