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

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
davephillips
Forum Newbie
Posts: 1
Joined: Fri Aug 14, 2009 10:06 am

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

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post 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'];
Post Reply