|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-05-12 21:18 UTC] girgias@php.net
-Status: Open
+Status: Not a bug
[2020-05-12 21:18 UTC] girgias@php.net
[2020-05-13 13:58 UTC] 6562680 at gmail dot com
[2020-05-13 14:00 UTC] 6562680 at gmail dot com
[2020-05-13 15:05 UTC] bugreports at gmail dot com
[2020-05-13 15:10 UTC] bugreports at gmail dot com
[2020-05-13 15:39 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ I know, i know... "you should use strict_types()" and so... But really guys, why, exactly, why string "0" will be converted to false while calling (bool) ? Please :/// Once i found same joke while comparing two values on usort(), fixed... now i remember used everywhere (! $string) and confused... little bit. Test script: --------------- function (string $name) { if (! $name) { // nice one, junior, you'll lose "0" right here // please rewrite your project and use ('' !== $name) or be fired throw new \InvalidArgumentException('String should be not empty'); } // some code } Expected result: ---------------- (bool) 0 === false (bool) "0" === true (bool) (string) 0 === true ... Actual result: -------------- (bool) 0 === false (bool) "0" === false (bool) (string) 0 === false ...