Is this a Bug in Php

Hi,

I am getting a wrong execution in logic and i cannot see anything wrong with the code and thus the only
reason this is failing maybe is a bug in Php itself.

That is please look at this code:



echo '<p>$num_fa: ' . $num_fa;
	   echo '<p>$nfa_2: ' . $nfa_2;

if ((0 > $num_fa) AND ($num_fa <= $nfa_2)) {
			$payment_due = $fa_payment_1;
			echo '<p>Hellow World 1';
		} else if (($nfa_2 > $num_fa) AND ($num_fa <= $nfa_3)) {
			$payment_due = $fa_payment_2;
			echo '<p>Hellow World 2';
		} else if (($nfa_3 > $num_fa) AND ($num_fa <= $nfa_4)) {
			$payment_due = $fa_payment_3;
			echo '<p>Hellow World 3';
		} else if ($num_fa > $nfa_4) {
			$payment_due = $fa_payment_4;
		}

Now consider the values in the above code as have been printed out using echo command:

$num_fa: 3

$nfa_2: 5

Hellow World 2

So the code should execute to print Hellow World 1 but instead it is going to Hellow World 2!

What the HEK is going on?

Regards,

Why would it print “Hellow World 1”?
The first condition (0 > $num_fa) is obviously false!
Think about it is $num_fa less than 0?
Me no think so.

You know I had gone for a 10K run, and right in the middle of my run I saw that I
had the > bracket rather than then > bracket for the 1st condition. I tell you
one must not program for than 8 Hours straight or one starts making the silliest
mistakes and worse one cannot even see them.

Good day :slight_smile:

everyone’s been there.