Image

Imagefunnel101 wrote in Imagephp 😯confused

Url/Filename Check Help?

Okay, here's what I want to have happen:

I want a link button to change color depending on web address. For example, on http://2cents4change.povertyprogram.com/news.php , I want the "News" button to be a different color than the rest. The CSS is already there. Usually, I set a variable on the page as I'm creating the page and then check for that variable. However, I didn't set those variables this time and would like to avoid editing every file on this webpage. So, I'm thinking of using the address or filename as the variable to check.

I've tried:

<php if($filename=="http://2cents4change.povertyprogram.com/news.php")
echo " class=\"rightcurrent\"";
else
echo " class=\"cents right\"";
?>

<php if($filename=="news.php")
echo " class=\"rightcurrent\"";
else
echo " class=\"cents right\"";
?>

<php if($url=="http://2cents4change.povertyprogram.com/news.php")
echo " class=\"rightcurrent\"";
else
echo " class=\"cents right\"";
?>

Any suggestions?

[EDIT: Figured it out! A friend of mine, who I worship as a PHP god, told me about "basename":

<?php
if (basename($_SERVER['REQUEST_URI'])=="news.php")
echo " class=\"cents rightcurrent\"";
else
echo " class=\"cents right\"";
?>
]