Closed remco-pc closed 1 month ago
So if I understand it correctly, this is basically the same to your original code: https://3v4l.org/nqaUa
Note that '0'
is a falsy value, so the "error" branch won't be taken, which is expected. Therefore you end up with "ok".
Unless I misunderstood, there's no bug here.
@nielsdos
<?php
/**
* same behaviour as in the template engine
* $list = [], list is empty
* $list = (object) [], list is not empty
* $list = false, list is empty
* $list = null, list is empty
* $list = 0, list is empty
* $list = 1, list is not empty
* $list = '', list is empty
* $list = '0', List is not empty', list is empty in template engine
*/
$list = '0';
var_dump($list);
$counter = null;
if($counter === 0){
}
elseif($list){
echo 'List is not empty';
}
else{
echo 'List is empty';
}
@nielsdos i see now, list is empty on 0, i swear it was not empty !, sorry for any inconvinient, the co-pilot did this wrong too and made me doubt...
Description
The following code:
Resulted in this output:
But I expected this output instead:
under the hood the "rax" template compiles down to php code where d is the debug function which outputs its a string '0' and it behaves like 0 for the first 2 elseifs the third, which is checking === under the hood is correct, but the other two should react first...
PHP Version
8.3.11
Operating System
Debian 12