Post vars problem |
[eluser]RecoilUK[/eluser]
Hi guys I have a piece of code that I am having issue's with ... post['char'] can be anything in the range of A-Z and 0-9 Code: if(!$this->input->post('char') === FALSE) { Now the problem comes when post['char'] is zero, as it validates to FALSE and then sets $character as A. How can I stop this? Any help would be appreciated. Thanks
[eluser]Massaki[/eluser]
Code: $character = $this->input->post('char');
[eluser]RecoilUK[/eluser]
Code: $character = $this->input->post('char'); That works though. Thanks
[eluser]Massaki[/eluser]
Sorry, try this: Code: $character = $this->input->post('char');
[eluser]CroNiX[/eluser]
@massaki input::post() will return a boolean FALSE if the POST key doesn't exist, so using is_null() is useless as it will never be null. It will either have the value from the POST array or be boolean FALSE. This will be changing in the future, but not in v2.x. So checking with === FALSE is the proper way; not checking for evaluating to false (!$character), which a 0 value will do too.
[eluser]Aken[/eluser]
Note that $this->input->post() (and similar methods) WILL return null as of CI 3.0, whenever it is released. |
Welcome Guest, Not a member yet? Register Sign In |