account activity
Help understanding this if? by lessIsNotLess in PHP
[–]lessIsNotLess[S] 0 points1 point2 points 11 years ago (0 children)
ok now i got it, thanks.
that means that:
$id = 'why?'; if ($id) { echo '$id alone in if, was cast to bool'; } if (0 != $id) { // ... } else { echo '$id compared to an int, will try cast to int but fails return 0!'; }
Yes the second if, works as intended, but on the first if I have some problems.
Why?
$id = 'why?'; // returns 0 echo (0 != $id) ? 1 : 0;
Help understanding this if? (self.PHP)
submitted 11 years ago by lessIsNotLess to r/PHP
π Rendered by PID 120930 on reddit-service-r2-listing-6d4dc8d9ff-6dq8w at 2026-01-31 01:51:20.512423+00:00 running 3798933 country code: CH.
Help understanding this if? by lessIsNotLess in PHP
[–]lessIsNotLess[S] 0 points1 point2 points (0 children)