[nycphp-talk] ${$variable}
Analysis & Solutions
danielc at analysisandsolutions.com
Wed Aug 27 18:22:05 EDT 2003
On Wed, Aug 27, 2003 at 05:59:41PM -0400, Chris Snyder wrote:
>
> if ( isset($foo) ) {
> if ( is_string($foo) && $foo=='' ) do stuff here
> }
The is_string() test is unnecessary. You can just do $foo === ''.
Back to the earlier stage of this discussion, if you're not concerned
about the 0, null or false, you can do this whole thing in one step with
an empty() test.
Again, your style is confusing. Your bracket is under the second if, even
though it's closing the first if. Let alone, I (and most style guides)
dislike single line if statements.
I just learned something interesting while confirming stuff:
$bar = 0;
if ($bar == '') {
echo '<br />bar equals empty';
}
This comparison will evaluate to true, so the message will be printed.
Weird,
--Dan
--
FREE scripts that make web and database programming easier
http://www.analysisandsolutions.com/software/
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7th Ave #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list