Bug #76710 [Opn->Nab]: result of empty() is not correct

From: Date: Mon, 06 Aug 2018 08:56:39 +0000
Subject: Bug #76710 [Opn->Nab]: result of empty() is not correct
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216631@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76710&edit=1 ID: 76710 Updated by: requinix@php.net Reported by: mehdimn dot mail at gmail dot com Summary: result of empty() is not correct -Status: Open +Status: Not a bug Type: Bug Package: Variables related Operating System: linux ubuntu PHP Version: 7.2.8 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://php.net/manual/en/function.empty.php > Note: > When using empty() on inaccessible object properties, the __isset() overloading method will be > called, if > declared. You need to implement __isset. In general, __get, __set, and __isset must all be implemented together for properties to work correctly. Previous Comments: ------------------------------------------------------------------------ [2018-08-06 08:50:39] mehdimn dot mail at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=76710&edit=1

« previous php.bugs (#216631) next »