我有两节课。
我想检查一个类是否是另一个类的实例而不初始化它们中的任何一个。
使用该功能is_subclass_of和使用时,instanceOf您必须初始化子类。
<?php
$classPath = 'app/foo/bar';
$subClassPath = 'app/foo/foo'; // Inherits from $classPath
// This is what I want to do but doesn't work.
echo $subClassPath instanceOf $classPath;
// Works
echo (new $subClassPath()) instanceOf $classPath;