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 ? Quote Link to comment 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; ?> Quote Link to comment 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 } Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.