I'm coding some PHP app and I'm receving some strange values from my code, example:
//Loop here lot of intval because i tried a lot of things
$testval=intval(intval($i/$dayspromo[$key])*$dayspromo[$key]);
echo "<br> val $testval counter $i bool<br>";
var_dump($i);
var_dump($testval);
var_dump($i-$testval);
echo "<br> again val ".$testval." y ".$i-$testval." comp <br>";
will print at $i=9:
val 8 counter 9 bool
int(9) int(8) int(1) -8 comp
As you can see something very bad happened, if i try to subtract $testval from $ii will get wrong values but var_dump will show the RIGHT value. Also first part of the second echo is missing and i don't know why.
How do i fix or debug this to fix it?
Thanks in advance
please try this:
echo "<br> again val ".$testval." y ".($i-$testval)." comp <br>";
if you forget the brackets it will happen something like this:
$string = "hello world"; // you have a string
$tmp = $string - 10; // substract 10 from string
// string will be converted to int and this is zero
// zero minus 10 is -10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.