Page 1 of 1

Newbie Question - what's wrong with this line of code?

Posted: Fri Aug 14, 2009 10:11 am
by davephillips
Forgive me, I'm a newbie at PHP.

Code: Select all

<?php if($_GET("add")) { echo "block"; } else { echo "none"; } ?>
It's not working. I'm trying to check for the existing of the add variable in the URL. I get no output on the page at all, nor any of the HTML that I have in the php module after this.

TIA,

Dave

Re: Newbie Question - what's wrong with this line of code?

Posted: Fri Aug 14, 2009 10:19 am
by jackpf
Unless you've replaced the $_GET array with a callable function, you'll probably want to use square (I think you can use curly as well) brackets.

If you turn on error reporting you'll probably get an error.

Try this instead:

Code: Select all

$_GET['add'];