|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-07-06 01:39 UTC] yohgaki@php.net
-Status: Open
+Status: Verified
[2017-05-19 10:41 UTC] jhabdas at gmail dot com
[2017-05-19 10:57 UTC] requinix@php.net
-Status: Verified
+Status: Duplicate
-Package: *General Issues
+Package: Scripting Engine problem
[2017-05-19 10:57 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 03:00:02 2025 UTC |
Description: ------------ PHP provides inaccurate NOTICE message regarding constants on class initialization. When you initialize new class, the error message does not point the line in the class which causes said error message, but points to a line where Class is initialized instead. Test script: --------------- // Foo.php <?php class Foo { const BAR = 1; protected $message = BAR; // <- this line is intentionally incorrect public function __construct($message) { $this->message = $message; echo "Initialized with {$this->message}"; } } // test.php <?php include 'Foo.php'; $var = new Foo(Foo::BAR); Expected result: ---------------- Expected result: Notice: Use of undefined constant BAR - assumed 'BAR' in Foo.php on line 5 Actual result: -------------- Actual result: Notice: Use of undefined constant BAR - assumed 'BAR' in test.php on line 3