(PHP 8 >= 8.2.0)
ReflectionClass::isReadOnly — 检查类是否为只读
此函数没有参数。
示例 #1 ReflectionClass::isReadOnly() 示例
<?php
class TestClass { }
readonly class TestReadOnlyClass { }
$normalClass = new ReflectionClass('TestClass');
$readonlyClass = new ReflectionClass('TestReadOnlyClass');
var_dump($normalClass->isReadOnly());
var_dump($readonlyClass->isReadOnly());
?>
上面的例子将输出
bool(false) bool(true)