Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

class_exists()

Look up a class name case-insensitively.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

class_exists(string $class, bool $autoload = true): bool

Look up a class name case-insensitively. By default an unknown name triggers registered autoloaders. Pass false to inspect only declarations already loaded. Enums also count as classes, while interfaces and traits have their own lookup functions.

Signature

class_exists(string $class, bool $autoload = true): bool

Example output

[true,false,false]

Examples

<?php
interface Taggable {} enum State { case Open; }
echo json_encode([class_exists("sTaTe",false),class_exists(Taggable::class,false),class_exists("UnloadedWidget",false)]);

Result

[true,false,false]

Sources