Oh, for a "sureset()" (orthogonal to isset())
weston_at_leary.csoft.net
Date: 10/30/03
- Next message: Chris Shiflett: "Re: [PHP] Problems with remote include"
- Previous message: Geoffrey Makstutis: "mime::decode and multipart"
- Next in thread: Al: "Re: Oh, for a "sureset()" (orthogonal to isset())"
- Reply: Al: "Re: Oh, for a "sureset()" (orthogonal to isset())"
- Reply: Tom Rogers: "Re: [PHP] Oh, for a "sureset()" (orthogonal to isset())"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: php-general@lists.php.net Date: Thu, 30 Oct 2003 14:31:01 -0500 (EST)
I'm sure I'm not the first person to find strict checking of whether
or not variable (or array index) is set painful. I've considered
just setting error_reporting() to some lax level on every script I
write for the rest of my life, but have been thinking there might
be a better way.
What I'd like is a "sureset()" function ...there's probably a better
name, but what it would do is more important:
function sureset($var) {
if(!isset($var) || empty($var))
return '';
else
return $var;
}
Of course, when you've got strict checking on, the above doesn't
work, because if the variable is unset you get caught on the fact
before the function call happens.
Is there something like this already? Is there a way to make this
work? Or should I just go back to the idea of nuking error_reporting
in all my scripts?
Thanks,
Weston
Thanks,
- Next message: Chris Shiflett: "Re: [PHP] Problems with remote include"
- Previous message: Geoffrey Makstutis: "mime::decode and multipart"
- Next in thread: Al: "Re: Oh, for a "sureset()" (orthogonal to isset())"
- Reply: Al: "Re: Oh, for a "sureset()" (orthogonal to isset())"
- Reply: Tom Rogers: "Re: [PHP] Oh, for a "sureset()" (orthogonal to isset())"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|