Hosting Solutions
mobile_logo Table of Contents

Using the class_exists Function

The class_exists() function is used to determine whether or not a class is defined in the script. It returns a boolean value of either TRUE or FALSE. demo.php <?php include_once("cart.php"); if(class_exists("cart")){ $shopping_cart = new cart(); echo $shopping_cart->store; } else { echo '"cart" class does not exist'; } ?> cart.php <?php class cart { public $store = "Spacely Sprockets"; public $items = array(); } ?>

PHP Videos

Object Oriented Programming

Class File Creation Tutorial Learn PHP OOPClass Properties and Methods Object Oriented ProgrammingConvert MySQL Timestamp to Ago Time Format OOP TutorialUsing the property_exists FunctionUsing the method_exists FunctionUsing the get_parent_class functionUsing the get_object_vars FunctionUsing the get_declared_classes FunctionUsing the get_class FunctionUsing the get_class_vars FunctionUsing the get_class_methods FunctionUsing the class_exists FunctionPassword Strength Check Script Class OOP TutorialExtend Class Object Oriented Programming OOP