Bug #76710 [NEW]: result of empty() is not correct

From: Date: Mon, 06 Aug 2018 08:50:39 +0000
Subject: Bug #76710 [NEW]: result of empty() is not correct
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216630@lists.php.net to get a copy of this message
From: mehdimn dot mail at gmail dot com Operating system: linux ubuntu PHP version: 7.2.8 Package: Variables related Bug Type: Bug Bug description:result of empty() is not correct Description: ------------ The result of empty($objA->g) is TRUE but result of var_dump or echo the $objA->g is a string value. Maybe help you to fix it, I found : https://bugs.php.net/bug.php?id=36786 Test script: --------------- <?php # test empty result class A { private $g = ''; public function __get($property) { return $this->$property; } function run() { $this->g = '4, 5, 6'; } function callA() { $clsB = new B(); $this->run(); $clsB->callB($this); } } class B { function callB($objA) { echo '<pre>'; var_dump($objA->g); // is not empty var_dump(empty($objA->g)); // result is TRUE !? echo '</pre>'; } } $a = new A(); $a->callA(); ?> Expected result: ---------------- FALSE Actual result: -------------- TRUE -- Edit bug report at https://bugs.php.net/bug.php?id=76710&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76710&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76710&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76710&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76710&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76710&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76710&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76710&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76710&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76710&r=support Expected behavior: https://bugs.php.net/fix.php?id=76710&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76710&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76710&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76710&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76710&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76710&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76710&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76710&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76710&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76710&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76710&r=mysqlcfg

« previous php.bugs (#216630) next »