The description say "(PHP 5, PHP 7)", but anonimous class is avaliable in php 7.
(PHP 7, PHP 8)
ReflectionClass::isAnonymous — 检查类是否是匿名类
此函数没有参数。
成功时返回 true
, 或者在失败时返回 false
。
示例 #1 ReflectionClass::isAnonymous() 示例
<?php
class TestClass {}
$anonClass = new class {};
$normalClass = new ReflectionClass('TestClass');
$anonClass = new ReflectionClass($anonClass);
var_dump($normalClass->isAnonymous());
var_dump($anonClass->isAnonymous());
?>
以上示例会输出:
bool(false) bool(true)
The description say "(PHP 5, PHP 7)", but anonimous class is avaliable in php 7.