homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

isset - how do you explain everything it does?

 8:02 pm on Sep 15, 2012 (gmt 0)

I kind of get isset function, but not entirely.
I understand it is mainly used with if statements.
Is it just for submitting forms? And what is the difference for isset with GET and POST?

If I use it for GET
e.g. if(isset($_GET['page']))
Does this check the url to see if there is a value for page?

And for POST, does it just mean, if the form submit button is clicked?



 8:09 pm on Sep 15, 2012 (gmt 0)

it's possible to set (or overwrite) a GET variable or a POST variable in your script, just be writing
$_GET['page'] = 'blah';
$_POST['page'] = 'blah';

so they don't have to come from a URL or a form (although they usually do).

i think isset just checks whether a variable exists. it doesn't care where it came from.


 8:17 pm on Sep 15, 2012 (gmt 0)

Oh, so it just checks if a variable exists, that makes sense.


 9:21 pm on Sep 15, 2012 (gmt 0)

IF "IS SET" (binary answer: yes/no) THEN...


 10:04 am on Sep 17, 2012 (gmt 0)

In case testing $_GET['page'] it only test that variable exists (as answered above). But it does not test if variable has value. From isset point of view there is no difference between ?page and ?page=index

If you want to test that variable has some data, you can use empty() - [php.net...]


 9:56 pm on Sep 17, 2012 (gmt 0)

Isset returns false if the specified variable (or array element) has not been defined or if it has been defined but was assigned a value of null.

Isset is not a function. It is a "language construct." It sounds like I'm being pendantic to point it out, but it is important to know because you can't, for example, reference it as a variable function or pass it to a method expecting a function.

-- Roger

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved