Bug #74152 [NEW]: if statement says true to a null variable

From: Date: Wed, 22 Feb 2017 21:34:31 +0000
Subject: Bug #74152 [NEW]: if statement says true to a null variable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207513@lists.php.net to get a copy of this message
From: kontakt at markus-kottlaender dot de Operating system: Linux Mint 18 PHP version: Irrelevant Package: Apache2 related Bug Type: Bug Bug description:if statement says true to a null variable Description: ------------ I have a php file containing exaclty the code below. It prints true when run in the browser but false when run on command line. I cleared my browser cache, hit ctrl+f5... I even changed the scripts file name. After making changes to this simple file (just adding whitespaces to the end) and hitting f5 in the browser it says false _once_ but than true again. PHP 7.0.13 and 7.0.15 Apache/2.4.18 Related question on Stackoverflow: http://stackoverflow.com/questions/41970037/if-statement-says-true-to-a-null-variable See the last comment: "I've verified that both the cli and Apache both use the same version and the output varies between both of them. I am out of idea's, except an update of the PHP version if its available. [...]" – Xorifelse I let him see it in action via team viewer and he verified that I'm not talking shit. Output of apt list --installed | grep php: libapache2-mod-php/xenial,xenial,now 1:7.0+35ubuntu6 all [installiert] libapache2-mod-php7.0/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php/xenial,xenial,now 1:7.0+35ubuntu6 all [installiert] php-cli-prompt/xenial,xenial,now 1.0.1+dfsg-1build1 all [Installiert,automatisch] php-common/xenial,xenial,now 1:35ubuntu6 all [Installiert,automatisch] php-composer-semver/xenial,xenial,now 1.2.0-1build1 all [Installiert,automatisch] php-composer-spdx-licenses/xenial,xenial,now 1.1.2-1build1 all [Installiert,automatisch] php-gd/xenial,xenial,now 1:7.0+35ubuntu6 all [installiert] php-gettext/xenial,xenial,now 1.0.11-2build1 all [Installiert,automatisch] php-intl/xenial,xenial,now 1:7.0+35ubuntu6 all [installiert] php-json-schema/xenial,xenial,now 1.6.1-1build1 all [Installiert,automatisch] php-mbstring/xenial,xenial,now 1:7.0+35ubuntu6 all [Installiert,automatisch] php-mysql/xenial,xenial,now 1:7.0+35ubuntu6 all [installiert] php-pear/xenial,xenial,now 1:1.10.1+submodules+notgz-6 all [Installiert,automatisch] php-phpseclib/xenial,xenial,now 2.0.1-1build1 all [Installiert,automatisch] php-symfony-console/xenial,xenial,now 2.7.10-0ubuntu2 all [Installiert,automatisch] php-symfony-filesystem/xenial,xenial,now 2.7.10-0ubuntu2 all [Installiert,automatisch] php-symfony-finder/xenial,xenial,now 2.7.10-0ubuntu2 all [Installiert,automatisch] php-symfony-process/xenial,xenial,now 2.7.10-0ubuntu2 all [Installiert,automatisch] php-xml/xenial,xenial,now 1:7.0+35ubuntu6 all [Installiert,automatisch] php7.0/xenial-updates,xenial-updates,now 7.0.15-0ubuntu0.16.04.1 all [installiert] php7.0-cli/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-common/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [Installiert,automatisch] php7.0-fpm/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-gd/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-intl/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-json/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-mbstring/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-mysql/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-opcache/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-readline/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] php7.0-xml/xenial-updates,now 7.0.15-0ubuntu0.16.04.1 amd64 [installiert] phpmyadmin/xenial-updates,xenial-updates,now 4:4.5.4.1-2ubuntu2 all [installiert] Test script: --------------- <?php $foo = 'foo'; $bar = null; switch ($foo) { default: case 'foo': if ($bar) { echo 'true'; } else { echo 'false'; } } Expected result: ---------------- false Actual result: -------------- true in browser, false on command line -- Edit bug report at https://bugs.php.net/bug.php?id=74152&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74152&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74152&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74152&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74152&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74152&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74152&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74152&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74152&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74152&r=support Expected behavior: https://bugs.php.net/fix.php?id=74152&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74152&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74152&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74152&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74152&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74152&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74152&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74152&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74152&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74152&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74152&r=mysqlcfg

« previous php.bugs (#207513) next »