- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
class_exists() function in PHP
The class_exists() function in PHP checks if the class has been defined. It returns TRUE if class is a defined class, else it returns FALSE.
Syntax
class_exists(class, autoload)
Parameters
class − Name of the class.
autoload − Whether to call __autoload or not by default
Return
The class_exists() function returns TRUE if class is a defined class, else it returns FALSE.
Example
The following is an example −
<?php if (class_exists('Demo')) { $demo = new Demo(); echo "Our class!"; } else { echo "Class does not exist"; } ?>
Output
The following is the output −
Class does not exist!
Advertisements