CodeIgniter Forums
isset: Strange behaviour - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: isset: Strange behaviour (/showthread.php?tid=6512)



isset: Strange behaviour - El Forum - 03-02-2008

[eluser]libnac[/eluser]
Someone knows why this sentence works

Code:
if(!isset($hello)) {
..
}

and this sentence doesn't work?

Code:
if(!isset($this->input->post("Ds_AuthorisationCode"))) {
..
}



isset: Strange behaviour - El Forum - 03-02-2008

[eluser]Matthew Lanham[/eluser]
Well i dont see any reason why the first one wouldn't work, as long as you have $hello set....on the second one using the codeigniter input class you don't need the isset, as if the POST variable is not set codeigniter would return false so you could try:

Code:
if($this->input->post("Ds_AuthorisationCode") == false){
   //Code here
}



isset: Strange behaviour - El Forum - 03-02-2008

[eluser]webthink[/eluser]
because $this->input->post("Ds_AuthorisationCode") is a function where as $hello is a variable. isset looks in memory for a variable with the name you pass it as opposed to just the value.