PHP | class_exists() Function Last Updated : 27 Apr, 2020 Comments Improve Suggest changes Like Article Like Report The class_exists() function is an inbuilt function in PHP which is used to check whether the given class is defined or not. Syntax: bool class_exists( string $class_name, bool $autoload = TRUE ) Parameters: This function accept two parameters as mentioned above and described below: $class_name: It holds the class name which need to check their existence. $autoload: It checks whether the __autoload is called or not by default. Return Value: This function returns True if class name is defined otherwise returns False. Below programs illustrate the class_exists() function in PHP: Program 1: php <?php // Create a class class GFG { public $Geek_name = "Welcome to GeeksforGeeks"; } // Check class name exist or not if(class_exists('GFG')) { echo "Class name exists"; } else { echo "Class name does not exist"; } ?> Output: Class name exists Program 2: php <?php // Creating class class GFG { public $data1; public $data2; public $data3; } if(class_exists('GFG')) { // Creating an object $obj = new GFG(); // Set values of $obj object $obj->data1 = "Geeks"; $obj->data2 = "for"; $obj->data3 = "Geeks"; // Print values of $obj object echo "$obj->data1 \n$obj->data2 \n$obj->data3"; } else { echo "Class does not exist"; } ?> Output: Geeks for Geeks Reference: https://www.php.net/manual/en/function.class-exists.php Comment More infoAdvertise with us Next Article PHP | class_exists() Function A ashokjaiswal Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-OOP Similar Reads PHP enum_exists() Function The enum_exists() is an inbuilt function in PHP that checks whether the enum is defined or not in the PHP script. Syntax: enum_exists(string $enum, bool $autoload = true) Parameters: This function has two parameters. $enum: The enum name.The name is match in an insensitive manner.$autoload: This par 1 min read PHP key_âexists() Function The key_exists() function is an inbuilt function in PHP that is used to check whether the given key exist in the given array or not. If given key exist in the array then it returns true otherwise returns false. This function is an alias of array_key_exists() function. Syntax: bool key_exists(string| 2 min read PHP file_exists( ) Function The file_exists() function in PHP checks whether a file or directory exists on the server. It returns a boolean value:true: If the file or directory exists.false: If the file or directory does not exist or the path is incorrect.Syntax:file_exists($path)In this syntax: The file_exists() function in P 2 min read PHP array_key_exists() Function The array_key_exists() function in PHP is a built-in function that checks whether a specified key exists in an array. This function is commonly used when working with associative arrays, where keys are explicitly defined, and we need to confirm the presence of a particular key to prevent errors or u 2 min read PHP | class_alias() Function The class_alias() function is an inbuilt function in PHP which is used to create an alias name of the class. The functionality of the aliased class is similar to the original class. Syntax: bool class_alias( string $original, string $alias, bool $autoload = TRUE ) Parameters: This function accepts t 2 min read PHP | get_class() Function The get_class() function is an inbuilt function in PHP which is used to return the class name of an object. Syntax: string get_class( object $object ) Parameters: This function accepts single parameter $object which holds the object that need to be tested. The value of this parameter can be omitted 1 min read PHPUnit assertFileExists() Function The assertFileExists() function is a builtin function in PHPUnit and is used to check whether an file path exists or not. This assertion will return true in the case if given file path exists else return false. In case of true the asserted test case got passed else test case got failed. Syntax: asse 2 min read PHP method_exists() Function The method_exists() function is an inbuilt function in PHP which used to check the class method exists or not. It returns "true" if the method exists otherwise returns "false". Syntax: bool method_exists( object|string $object_or_class, string $method );Parameters: This function accepts two paramete 1 min read PHP class_uses() Function The class_uses() function is an inbuilt function in PHP where the traits utilized by the given class, will be returned. Syntax: class_uses($object_or_class,$autoload = true): array|false Parameters: This function accepts the two parameters that are described below object_or_class: The name of the cl 2 min read PHP | DsSet contains() Function The Ds\Set::contains() function is an inbuilt function in PHP which is used to check the given value exists in the set or not. This function compares the value and its type. Syntax: bool public Ds\Set::contains( $values ) Parameters: This function accepts a single or many values which need to check 1 min read Like