laubacht
asked on
PHP Basename Question
The code is pretty simple, but yet it still prints false... here is the live link..
http://www.tornadoeskick.com/tonylaubach/codeTest.php
Obviously the filename is codeTest.php, but it won't display true for some reason? Any suggestions?
http://www.tornadoeskick.com/tonylaubach/codeTest.php
Obviously the filename is codeTest.php, but it won't display true for some reason? Any suggestions?
<?php
$myURL=basename(basename($_SERVER['REQUEST_URI']));
echo "$myURL";
?>
<br><br>
<?php
if ( $myURL == codeTest.php ) {
echo "The if statement evaluated to true";
} else {
echo "The if statement evaluated to false";
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@g3nu1n3 is right. Without the quotes, PHP looks for a constant by that name and of course it doesn't find it.
Grab a copy of this book. It will not make you a pro, but it will give you enough of a foundation in the basics of PHP to avoid simple syntax errors like this one.
http://www.sitepoint.com/books/phpmysql5/
Sidebar note: You only need to call the basename() function once.
Second sidebar note: Learn about this function:
http://us2.php.net/manual/en/function.var-dump.php
Best of luck with your PHP adventures, ~Ray
http://www.sitepoint.com/books/phpmysql5/
Sidebar note: You only need to call the basename() function once.
Second sidebar note: Learn about this function:
http://us2.php.net/manual/en/function.var-dump.php
Best of luck with your PHP adventures, ~Ray
ASKER
The quotes did it... I appreciate the fast help on that! Working a website without using Wordpress or something along those lines, so doing a lot of this from scratch! Thanks guys!
error_reporting(E_ALL);
and quotes around the script name.