[clug] need another set of eyes - PHP when no variable is passed

Robert Edwards bob at cs.anu.edu.au
Thu Mar 30 03:23:53 GMT 2006

Kristy A. Bennett wrote:
> Okay,
> It's just one of those days >:o
> Okay so here's the dilemma.  I have a page - say index.php which has a 
> variable 'menu' to be passed back to itself.  This variable is then used 
> to call in flash movie (yeah, yeah I know....).  This part was working 
> and but I have since broken it again.  However, the problem does not lie 
> here.
> I cannot for the life of me work out how to set a default variable if 
> one is not passed (eg user goes to index.php as opposed to 
> index.php?menu="about").
> I have tried if(!$menu) {blah} and if ($menu=="") {blah}.  Neither work 
> - is there any other solution that I have just simply overlooked?

You could use a session cookie (see PHPs session_start () etc.
functions). The actual variable is then held on the server, not sent
back and forth to the client browser.


Bob Edwards.

More information about the linux mailing list