Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can 2 > 10 be true in PHP?

I am now staring at my code:

if(2 > 10) echo "$#@$#$#$";

and the results are that the string is echoed on the page! So how can this be possible?

If I do this:

$i = 2;
$j = 10;
if($i > $j) echo "$#@$#$#$";

my script generates a 500 error.

And if I do this:

$i = 2;
if($i > 10) echo "$#@$#$#$";

I get this error message:

Notice: Use of undefined constant  10 - assumed ' 10'

What could be the reason for this behavior?

like image 630
Kaptnkill Avatar asked Dec 28 '25 21:12

Kaptnkill


1 Answers

Will probably works fine :

if(2 >10) echo "$#@$#$#$";

You may have an encoded whitespace you cannot see before 10 (wich is why it's saying assumed ' 10' and not '10')

like image 67
Gérald Croës Avatar answered Dec 30 '25 16:12

Gérald Croës



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!