2015-12-08 17:40:42 +08:00
|
|
|
--TEST--
|
|
|
|
Class private constant visibility
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class A {
|
|
|
|
private const privateConst = 'privateConst';
|
|
|
|
static function staticConstDump() {
|
|
|
|
var_dump(self::privateConst);
|
|
|
|
}
|
|
|
|
function constDump() {
|
|
|
|
var_dump(self::privateConst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
A::staticConstDump();
|
|
|
|
(new A())->constDump();
|
2020-01-10 19:01:42 +08:00
|
|
|
try {
|
|
|
|
constant('A::privateConst');
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2015-12-08 17:40:42 +08:00
|
|
|
|
|
|
|
?>
|
2020-01-10 19:01:42 +08:00
|
|
|
--EXPECT--
|
2015-12-08 17:40:42 +08:00
|
|
|
string(12) "privateConst"
|
|
|
|
string(12) "privateConst"
|
2020-01-10 19:01:42 +08:00
|
|
|
Cannot access private const A::privateConst
|