1--TEST-- 2Class private constant visibility 3--FILE-- 4<?php 5class A { 6 private const privateConst = 'privateConst'; 7 static function staticConstDump() { 8 var_dump(self::privateConst); 9 } 10 function constDump() { 11 var_dump(self::privateConst); 12 } 13} 14 15A::staticConstDump(); 16(new A())->constDump(); 17try { 18 constant('A::privateConst'); 19} catch (Error $e) { 20 echo $e->getMessage(), "\n"; 21} 22 23?> 24--EXPECT-- 25string(12) "privateConst" 26string(12) "privateConst" 27Cannot access private constant A::privateConst 28