Q:

How to see if a class is an instance of another class without creating either class?

I have two classes.
I want to check if a class is an instance of another class without initializing either of them.
With the function is_subclass_of and when using instanceOf you have to initialize the sub class.
<?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;

A:

I found the problem.
is_subclass_of requires your slashes to go the other way.
$classPath = 'app\foo\bar';
$subClassPath = 'app\foo\foo'; // Inherits from $classPath

// Works
echo is_subclass_of($subClassPath $classPath);

