PHP 8.3.0 RC 6 available for testing

ReflectionClass::isReadOnly

(PHP 8 >= 8.2.0)

ReflectionClass::isReadOnlyChecks if class is readonly

说明

public ReflectionClass::isReadOnly(): bool

Checks if a class is readonly.

参数

此函数没有参数。

返回值

true if a class is readonly, false otherwise.

示例

示例 #1 ReflectionClass::isReadOnly() example

<?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)

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top