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? 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] 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. 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. 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 Link to comment https://forums.phpfreaks.com/topic/15526-if-page-somethingphp/#findComment-63059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.