Understanding PHP's way of reading if statements
Posted
by Masi
on Stack Overflow
See other posts from Stack Overflow
or by Masi
Published on 2009-08-23T04:29:02Z
Indexed on
2010/05/12
23:44 UTC
Read the original article
Hit count: 147
How does PHP read if statements?
I have the following if statements in this order
if ( $number_of_figures_in_email < 6) {
-- cut: gives false
}
if($number_of_emails > 0) {
-- cut: gives false
}
if ( $number_of_emails == 0) {
-- cut: gives true
}
The code behaves randomly. It sometimes goes to the third if clause and gives me a success, while sometimes to the one of the first two if clauses when the input variables are constant.
This suggests me that I cannot code only with if statements.
© Stack Overflow or respective owner