Re: isset
| From: | Jim Lucas | Date: | Mon, 16 Apr 2007 17:28:20 +0000 |
| Subject: | Re: isset | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253034@lists.php.net to get a copy of this message | ||
Stut wrote:
Jim Lucas wrote:It use to through E_NOTICE warnings, as far back as I can remember back in 1999, and 2000 I wonder if they changed it, or the person that told me to do it that way was mistaken. my mistake. But, as you can tell, others were under the same impression as I. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - RushStut wrote:No you won't. The empty function does not raise a notice if its argument does not exist. From http://php.net/empty... "empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set." -Stut Interesting, have not looked at the empty() man page in a long time.tedd wrote:these two lines are not the same infact, with the first, you will not get a E_NOTICE warning, but with the second you will.At 4:08 PM +0100 4/16/07, Stut wrote:In the above example, if (isset($_GET['something']) && !empty($_GET['something'])) { is the same as... if (!empty($_GET['something'])) { So, in that particular line of code the isset is a pointless waste of cycles. -StutJim Lucas wrote:I've been accuse of that too, but what's your solution?Richard Kurth wrote:The isset is a pointless waste of cycles. -StutWhat do you do when isset does not work? If I send data in a $_REQUEST['var'] like if (isset($_REQUEST['var'])) { } Put var has no data it still says it is set. Because $_REQUEST['var'] = "" and isset thinks "" is setI use this combination a lot: if ( isset($_GET['something']) && !empty($_GET['something']) ) {// do something here with $_GET['something']}