Re: PHP not working, giving "undefined variable"
| From: | Leif K-Brooks | Date: | Sat, 24 May 2003 21:09:52 +0000 |
| Subject: | Re: PHP not working, giving "undefined variable" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148880@lists.php.net to get a copy of this message | ||
There IS an error, actually. Checking !$submit first converts $submit to boolean (http://us3.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting). If the variable isn't set at all (as opposed to being set to nothing), PHP generates a notice (since you're accessing an unset variable) and returns a NULL value. This has the desired effect, but is still wrong. To avoid the notice, use !isset($submit) instead.
PHP Spooky wrote:
And that was actually very stupid. You're right, do we give var $submit? I mean there was actually no error.. and if you have the reporting on, it makes it an error. Thanks, PHPSpooky -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.