Re: isset() question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux