|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-04-25 16:15 UTC] peehaa@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: peehaa
[2018-04-25 16:15 UTC] peehaa@php.net
[2018-04-25 16:19 UTC] peehaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 09:00:01 2025 UTC |
Description: ------------ I try to do an array access wrapped with empty on a constant array and a notice is thrown. I expected that empty would simply return false in the case the key is not found. Test script: --------------- <?php class Test { const FOO = ["a" => 0, "b" => 1, "b" => 2, "d" => 3]; public function getTest() { $a = ["a" => 0, "b" => 1, "b" => 2, "d" => 3]; var_dump(empty($a["not_found"])); $b = self::FOO; var_dump(empty($b["not_found"])); var_dump(empty(self::FOO["not_found"])); } } $a = new Test(); $a->getTest(); Expected result: ---------------- bool(true) bool(true) bool(true) Actual result: -------------- bool(true) bool(true) <br /> <b>Notice</b>: Undefined index: vsqsc in <b>[...][...]</b> on line <b>9</b><br /> bool(true)