mirror of
https://github.com/php/php-src.git
synced 2026-04-18 05:21:02 +02:00
Strangely, uses of eval and 'php -a' (or loading a file without opcache after a namespaced constant was declared)
will not treat non-FQ true/false/null as magic keywords, while compiled php required from a file would do that.
This may confuse people learning the language, and result in code loaded with
eval() behaving differently from the same snippet in a file loaded by require.
```
Interactive shell
php > define('foo\true', 'test');
php > namespace foo { var_dump(true); }
string(4) "test"
```
This will make the same session instead properly emit `bool(true);` like it
already would if running those statements in files when opcache was used.
(cherry picked from commit 4c48fd22d7)
23 lines
449 B
PHP
23 lines
449 B
PHP
--TEST--
|
|
eval() constant resolution
|
|
--FILE--
|
|
<?php
|
|
namespace foo {
|
|
define('foo\true', 'test');
|
|
echo "In eval\n";
|
|
eval('namespace foo { var_dump(true); var_dump(TrUe); var_dump(namespace\true); var_dump(\true); }');
|
|
echo "Outside eval\n";
|
|
var_dump(true); var_dump(TrUe); var_dump(namespace\true); var_dump(\true);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
In eval
|
|
bool(true)
|
|
bool(true)
|
|
string(4) "test"
|
|
bool(true)
|
|
Outside eval
|
|
bool(true)
|
|
bool(true)
|
|
string(4) "test"
|
|
bool(true)
|