Lessur Posted July 24, 2006 Share Posted July 24, 2006 How can I make a code like:<?php if $page == 'blah.php'; {echo "blah";}else{echo "blahblah"; }?>Where $page = the page. Like if you were at login.php wit would be login.php.How can I tell it that $page = the filename of the page? Quote Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/ Share on other sites More sharing options...
king arthur Posted July 24, 2006 Share Posted July 24, 2006 Try[code]$page = basename($_SERVER['PHP_SELF']);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/#findComment-63055 Share on other sites More sharing options...
ChaosXero Posted July 24, 2006 Share Posted July 24, 2006 There is a variable called $_SERVER['PHP_SELF'] that gets the current script location. Be warned, this will return very strange results on shared hosting. It gives something completely off base on my shared hosting.EDIT: What does 'basename' do?EDIT EDIT: php.net/basename shed some light on this, it fixes the problem I mentioned. Silly me. Sorry about that. Quote Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/#findComment-63057 Share on other sites More sharing options...
Lessur Posted July 24, 2006 Author Share Posted July 24, 2006 Ah, ok, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/#findComment-63058 Share on other sites More sharing options...
ryanlwh Posted July 24, 2006 Share Posted July 24, 2006 basename returns the filename component of a pathhttp://us2.php.net/manual/en/function.basename.php Quote Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/#findComment-63059 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.