is_a() Versus Instanceof
<?php
class A {}
var_dump(new a instanceof A);
// true
var_dump(new a instanceof A::class);
// Fatal error
var_dump(is_a(new a, A::class));
// true
var_dump(is_a(new a, A);
// Undefined constant A
is_a() and instanceof are the same feature: check if an object is of a specific class. Yet, they do things in different ways.
Using the ::class operator is safe in both cases.
Using a name is a class name for instanceof, while it is a constant name with is_a(). This may lead to confusion.
See Also
PHP Features
Last updated: 10 September 2026