[PHP-NOTES] note 130638 added to function.class-exists

[email protected] ("Anonymous") Tue, 03 Feb 2026 20:52:50 +0000
Newsgroups php.notes
Message-ID <[email protected]>
Beware that class_exists is a runtime check and not a compile time check!

This means that even if the class is defined after the class_exists, it will return true!

<?php

echo 'Does class "MyClass" exist? : ', class_exists('MyClass') ? 'YES' : 'NO';

class MyClass
{
}

?>

Output: YES
----
Server IP: 206.189.2.9
Probable Submitter: 95.98.156.14
----
Manual Page -- https://php.net/manual/en/function.class-exists.php
Edit        -- https://main.php.net/note/edit/130638
Del: integrated  -- https://main.php.net/note/delete/130638/integrated
Del: useless     -- https://main.php.net/note/delete/130638/useless
Del: bad code    -- https://main.php.net/note/delete/130638/bad+code
Del: spam        -- https://main.php.net/note/delete/130638/spam
Del: non-english -- https://main.php.net/note/delete/130638/non-english
Del: in docs     -- https://main.php.net/note/delete/130638/in+docs
Del: other reasons-- https://main.php.net/note/delete/130638
Reject      -- https://main.php.net/note/reject/130638
Search      -- https://main.php.net/manage/user-notes.php