Show depending on page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mywwd
Forum Newbie
Posts: 6
Joined: Mon Aug 02, 2010 12:20 am

Show depending on page

Post by mywwd »

I'm trying to figure out to show a panel on a page based upon the url.

i've tried
if ($_SERVER['PHP_SELF'] == profile.php) {
echo "coding"
}

and it just shows it on everypage. I am using this in my header page for a menu
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Show depending on page

Post by shawngoldw »

I am not sure if this is a complete solution, but the proper way to compare strings is:

Code: Select all

strcmp($str1, $str2) == 0
If it equals 0 then the strings are the same


Shawn
mywwd
Forum Newbie
Posts: 6
Joined: Mon Aug 02, 2010 12:20 am

Re: Show depending on page

Post by mywwd »

$str1 = $_SERVER['PHP_SELF'];
$str2 = "users.php?id=" . $_GET[id];
if (strcmp($str1, $str2) == 0) {
echo "test<br>";
echo $_SERVER['PHP_SELF'];
}

Doing it like this still shows the information all the time on every page
Post Reply