PHP || (and) operator question
I am trying to make my navigation to change color when selected. the class for selected is "current"
so I wrote this:
<ul class="<?php if(myfullpath() == "http://www.domain.com/first.php" || "http://www.domain.com/second.php"){echo "current";} else echo " "; ?>">
so if the url in the address bar is not first.php or second.php it should return false and echo " ", but for some odd reason this is returning true and posting class="current"> even if the url is posting http://www.domain.com/fourth.php .
JUST FYI here is the myfullpath function:
function myfullpath() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); }
thanks for your help.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks