|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-21 01:44 UTC] mberchtold at gmail dot com
Description:
------------
When a class that uses a constant with a namespace prefix is preloaded, using the class results in a fatal error.
Test script:
---------------
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_undef_const_4.inc
preload_undef_const_4.inc:
<?php
namespace mytest;
define(__NAMESPACE__ . '\CONSTANTINE', 'value');
class Test
{
public function __construct()
{
echo CONSTANTINE;
}
}
--FILE--
<?php
new \mytest\Test();
Expected result:
----------------
no error
Actual result:
--------------
PHP Fatal error: Uncaught Error: Undefined constant
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 20:00:01 2025 UTC |
The class "Test" is preloaded, but the script still has to be included or required (it's cached by opcache). <?php include("preload_undef_const_4.inc"); new \mytest\Test();