Forum Moderators: coopster

Message Too Old, No Replies

PHP $ GET and NULL value

         

arturito

6:26 pm on Jul 19, 2009 (gmt 0)

10+ Year Member



If I pass value by URL such as

index.php?id="" // would be empty string?
index.php?id='' // would be NULL value?

In my code I can prevent these by using empty() and is_null() functions?

penders

11:25 pm on Jul 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No. Anything after the equals is assigned to your variable ($_GET['id]). Quotes do not delimit string values in URL parameters. So, in your first example your variable would actually contain two double quote characters and your second example would contain two single quote characters.

In the case of...

index.php?id=

Where literally nothing occurs after the equals then you can check for this with empty() - an empty string is returned. The value is NOT null.

andrewsmd

2:19 pm on Jul 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you need to prevent that from being passed by checking for this
if($_GET['id'] == "" ¦¦ $_GET['id'] == ''){

echo("id is empty");
//this is your case of empty
//do whatever you want in code here

}//if