I tried running this simple php code in 2 different machines and i get different results for some reason.
the code:
<?php
$a = 5;
$b = "22ff67";
$s = $a - $b;
echo $s;
?>
in machine 1 i get the error:
Notice a non well former numeric value encountered in .... on line 4 17
and in machine 2 i get: -17
Notice: Use of undefined constant - assumed '' in C:\xampp\htdocs\aa.php on line 5
i run the code using XAMPP apache server...
- what could be the reason for the different results?
- the output is -17 because it tries to subtract 22 from 5 but because 22 is part of a string it gives the error? (it takes only 22 because it's the number before the first letter in the string (in strings which has signs other than '.', 'e','E' it takes the first number up to a sign other than those)
Thanks.