UnknownPlayer Posted September 13, 2010 Share Posted September 13, 2010 Why this code dont work :S <?php echo ' <ul> <li'; if ($_SERVER['PHP_SELF'] == "kategorije.php") { echo ' id="current"'; } echo '><a href="kategorije.php"><span>Kategorije</span></a></li> </ul>'; ?> Checking if PHP_SELF is "kategorije.php" do not work, why, and what is solution ? Link to comment https://forums.phpfreaks.com/topic/213328-links-current-page/ Share on other sites More sharing options...
Rifts Posted September 14, 2010 Share Posted September 14, 2010 <?php # Using HTTP_HOST $domain = $_SERVER['HTTP_HOST']; echo $domain; ?> Link to comment https://forums.phpfreaks.com/topic/213328-links-current-page/#findComment-1110855 Share on other sites More sharing options...
the182guy Posted September 14, 2010 Share Posted September 14, 2010 Why this code dont work :S <?php echo ' <ul> <li'; if ($_SERVER['PHP_SELF'] == "kategorije.php") { echo ' id="current"'; } echo '><a href="kategorije.php"><span>Kategorije</span></a></li> </ul>'; ?> Checking if PHP_SELF is "kategorije.php" do not work, why, and what is solution ? It doesn't work because PHP_SELF contains the path aswell as the filename, e.g. /my/path/kategorije.php use basename() to remove the path and it will work, like this if(basename($_SERVER['PHP_SELF']) == 'kategorije.php') { // do something } Link to comment https://forums.phpfreaks.com/topic/213328-links-current-page/#findComment-1110867 Share on other sites More sharing options...
UnknownPlayer Posted September 14, 2010 Author Share Posted September 14, 2010 Why this code dont work :S <?php echo ' <ul> <li'; if ($_SERVER['PHP_SELF'] == "kategorije.php") { echo ' id="current"'; } echo '><a href="kategorije.php"><span>Kategorije</span></a></li> </ul>'; ?> Checking if PHP_SELF is "kategorije.php" do not work, why, and what is solution ? It doesn't work because PHP_SELF contains the path aswell as the filename, e.g. /my/path/kategorije.php use basename() to remove the path and it will work, like this if(basename($_SERVER['PHP_SELF']) == 'kategorije.php') { // do something } Thanks it works this way. I thought $_SERVER['PHP_SELF'] is file name.. :S Link to comment https://forums.phpfreaks.com/topic/213328-links-current-page/#findComment-1111066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.