Re: isset

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

 



On Mon, 2007-04-16 at 18:16 +0100, Stut wrote:
> Jim Lucas wrote:
> > Stut wrote:
> >> tedd wrote:
> >>> At 4:08 PM +0100 4/16/07, Stut wrote:
> >>>> Jim Lucas wrote:
> >>>>> Richard Kurth wrote:
> >>>>>> What 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 set
> >>>>>>
> >>>>> I use this combination a lot:
> >>>>>
> >>>>> if ( isset($_GET['something']) && !empty($_GET['something']) ) {
> >>>>>     // do something here with $_GET['something']
> >>>>> }
> >>>>
> >>>> The isset is a pointless waste of cycles.
> >>>>
> >>>> -Stut
> >>>
> >>> I've been accuse of that too, but what's your solution?
> >>
> >> 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.
> >>
> >> -Stut
> >>
> > 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.
> 
> 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."

Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux