How to compare the value of the_permalink() with another function.
-
Im trying to develop a little hack for an ajax type menu. What i want to do is change the class of an “a” tag according to if the value of the_permalink matches the value of another function.
Here is the function i wish to check whether the_pemalink is equal to:
<?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?>
So on my “a” tag class i have tried the following:
<a class="<?php if (curPageURL() == the_permalink() ) { echo "on";} else {echo "off";} ?>" href="#">Test</a>
What appears to be happening is the permalink is being echo’d so i get a class output of:
<a class="www.mysite.com/?p=7off" href="#">test</a>
Im pretty new to PHP scripting so your patience is much appreciated. What would i need to do in order to check both functions and echo the relevant output?
Thank you very much in advance.
- The topic ‘How to compare the value of the_permalink() with another function.’ is closed to new replies.