Re: isset

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

 



On Mon, 2007-04-16 at 09:27 -0700, Jim Lucas wrote:
> 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
> > 
> well, as the OP said, he wants to know when the variable has a value other the "".
> 
> So, to check for that you have to do something like this right?
> 
> 	if ( $var != '' ) {}
> 	if ( strlen($var) > 0 ) {}
> 	if ( !empty($var) ) {}
> 	... a number of other ideas come to mind, but
> 
> none of them will work, because they will always product a E_NOTICE warning.
> 
> You COULD always use empty() prefixed with an @ to quiet the E_NOTICE,

Stut wouldn't do that... especially not after calling isset() a waste of
cycles. using the @ to suppress warnings/errors still invokes the error
system, and that includes any error handler you've custom hooked.

Maybe Stut just writes bad code ;) ;)

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