Bug #74152 [Opn->Csd]: if statement says true to a null variable
| From: | laruence@php.net | Date: | Thu, 23 Feb 2017 04:48:25 +0000 |
| Subject: | Bug #74152 [Opn->Csd]: if statement says true to a null variable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74152&edit=1
ID: 74152
Updated by: laruence@php.net
Reported by: kontakt at markus-kottlaender dot de
Summary: if statement says true to a null variable
-Status: Open
+Status: Closed
Type: Bug
Package: Apache2 related
Operating System: Linux Mint 18
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=330a7b62c3558aa987ee80e12f1914347d3a9eee
Log: Fixed bug #74152 (if statement says true to a null variable)
Previous Comments:
------------------------------------------------------------------------
[2017-02-22 21:34:27] kontakt at markus-kottlaender dot de
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 this bug report at https://bugs.php.net/bug.php?id=74152&edit=1