$variable ghosts

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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

$variable ghosts

Post by Gen-ik »

I was wondering if it's possible to send a 'dead' or 'ghost' variable to a PHP page... like this... my_php_page.php?BOB

...and then in the PHP page check if BOBs 'ghost' is there?

I've tried

Code: Select all

<?php isset($BOB); ?>
but it tells me that BOB doesn't exist. Is there another way of checking?

There is a reason for me wanting to do this but I don't want to do something like... my_php_page.php?BOB=1 ...even though I know it will work.

Any ideas?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

so you wana send a variable with no value?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

er.. yep. That sums it up nicely. :)

Can it be done?
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

sure you can


thesite.php?BOB=&
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

that wont work, as php will convert this to a string value conaining nothing.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Basically I'm just trying to make things look tidy.

Instead of the url looking something like news.php?latest=1, or news.php?latest=true.... I'm just trying to see if it's possible to just use news.php?latest

..maybe I should checkout the $POST variables and stuff to see if that can see a 'ghost' variable...... or even rip apart the url in PHP and see what's at the end of it.

Any suggestions would be cool :)
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

Post by RTT »

woooo, my first post here!

Perhaps you could use...

Code: Select all

$check = explode("?", $_SERVER['REQUEST_URI']);

if($check[1] == 'latest') {

        //show latest news

} else {

        //do something else
}
Seems to work -- links...
http://richthetitch.net/php/uri.php
http://richthetitch.net/php/uri.php?latest

8)
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Ah... sweet. Just what I was after... good 'ol PHP :)

Cheers mate.
jamesm87
Forum Newbie
Posts: 21
Joined: Sat May 31, 2003 1:54 pm
Location: London, UK

Post by jamesm87 »

Surly to check Isset you have to do it in an If Clause

eg

Code: Select all

<?php
if (isset($ghost))
{
blah
}
?>
But then again I might just have the wrong Idea!
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

jamesm87 wrote:Surly to check Isset you have to do it in an If Clause
Yeah I know I was just being lazy and lot typing all the code :wink:

?>
Post Reply