Nice of you to try and sidetrack with the personal bit.. I'll leave it at that incase you get uppity about it again.
-
if() does not check for data. if() checks for boolean FALSE as the result of it's argument. That is it. Upon finding false, it skips to the closing brace, or to a secondary condition (elseif) or opposing statement (else.)
The if() statement typecasts the output of it's criteria to boolean. It is PHP's management of types that cause 0 (integer zero), '0', '', 'false' (string) to boolean FALSE.
Try it.
Code: Select all
<?php
$var = (bool) 0;
var_dump($var);
?>
It DOES NOT check for content, it DOES NOT look at what you pass it and decided upon what type of variable it is, it does NOTHING more than evaluate the
result of the condition inbetween the accompanying parenthesis.
I have given you the facts, you chose to ignore them.
Pimptastic has agreed it is bad practice, but you STILL persist in claiming you are right, you are NOT.
I said twice that $_POST is undefined, as a
sideline to what the main point is - that main point being, incase you chose to ignore it yet again, that
is the
incorrect and
improper way to check that the $_POST array is empty.
This is exactly what empty() and isset() are for.
Just think about it..
is 1 > 0? boolean TRUE..
Code: Select all
<?php
if ('string' == 'different string') {
//blah
}
?>
boolean TRUE.
if's are not used with any other type of condition, it is always 'does the result of this condition equate to TRUE, or FALSE?' There isn't a sub-section to if() that says 'does this array contain any data?'