Re: isset() question
| From: | Jason Barnett | Date: | Tue, 30 Mar 2004 02:54:17 +0000 |
| Subject: | Re: isset() question | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23302@lists.php.net to get a copy of this message | ||
Anthony Ritter wrote:
The following script is from Kevin Yank's book (Sitepoint). When I test it _without_ entering a name in the text box and hit submit, the _next_ page loads - however the same page should load beacuse of the conditional ........ if (!isset($name) ): ..... If I replace !isset()This only checks if a variable has not been set. Any value, including an empty string "" can cause !isset($name) to fail; this is correct.
with empty() like if (empty($name)):Right... now you're checking if $name is empty. Empty($name) would fail this test, which is correct also.
and do not enter a name then the _same_ page loads which is what is supposed to happen. Why doesn't the call to !isset() with the negation mark loads the next page when a name is not entered?Because the tutorial writer meant it to work that way? Sometimes it is useful to pass empty strings to a php script. But in any case, you understand the PHP functions correctly.