(PHP 7, PHP 8)
ReflectionClass::isAnonymous — 检查类是否是匿名类
此函数没有参数。
示例 #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)