Welcome Guest, Not a member yet? Register   Sign In
Noobish question: Why unset a variable?
#7

[eluser]obiron2[/eluser]
A lot of the time, ! isset is being used to ensure that the module has been reached from the right point and in the right manner.

e.g. is you are trying to visit a secure part of the site and just type in the URL, you might want your code to say

if (! isset($_POST['userID']))

to check that the user ID has been passed as part of the form. If it has not then you know the URL has not been reached from the proper channels.

The other big use for it that I make is to validate checkboxes. If a checkbox is not ticked in a form then the name does not get passed in the form submission as part of $_POST.

if (isset($_POST['permit_emails'])) will return false if the permit emails box was not ticked.


obiron


Messages In This Thread
Noobish question: Why unset a variable? - by El Forum - 09-14-2008, 04:55 PM
Noobish question: Why unset a variable? - by El Forum - 09-14-2008, 05:16 PM
Noobish question: Why unset a variable? - by El Forum - 09-14-2008, 05:22 PM
Noobish question: Why unset a variable? - by El Forum - 09-14-2008, 10:00 PM
Noobish question: Why unset a variable? - by El Forum - 09-14-2008, 10:33 PM
Noobish question: Why unset a variable? - by El Forum - 09-15-2008, 04:24 AM
Noobish question: Why unset a variable? - by El Forum - 09-15-2008, 06:24 AM
Noobish question: Why unset a variable? - by El Forum - 09-15-2008, 06:25 AM
Noobish question: Why unset a variable? - by El Forum - 09-15-2008, 07:17 AM
Noobish question: Why unset a variable? - by El Forum - 09-15-2008, 04:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB