PHP interface_exists() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The interface_exists() function is an inbuilt function in PHP that checks interface is defined or not. Syntax: bool interface_exists(string $interface, bool $autoload = true)Parameters: This function accept two parameters that are described below: $interface: This parameter holds the interface name.$autoload: This parameter checks whether to call autoload or not by default.Return Value: If the given interface is defined, then it returns "true", otherwise it will return "false". Example 1: In this example, we will check interface is defined or not by using the interface_exists() function. PHP <?php if (interface_exists('MyInterface')) { class MyClass implements MyInterface { } echo "A class using 'Interface' is created."; } else { echo "'Interface' do not exist!."; } ?> Output: 'Interface' does not exist! Example 2: In the below code example, we will define an interface and then use the interface_exists() function. PHP <?php interface MyInterface{ public function hello() ; } if (interface_exists('MyInterface')) { class MyClass implements MyInterface { function hello(){ echo "Hey GeeksforGeeks"; } } echo "A class using 'Interface' is created.\n"; } else { echo "'Interface' does not exist!."; } $MyInterface = new MyClass() ; $MyInterface->hello() ; ?> Output: A class using 'Interface' is created. Hey GeeksforGeeks Reference: https://www.php.net/manual/en/function.interface-exists.php Comment More infoAdvertise with us Next Article PHP interface_exists() Function neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Classes/Object-Functions Similar Reads 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 | function_exists() Function The function_exists() is an inbuilt function in PHP. The function_exists() function is useful in case if we want to check whether a function() exists or not in the PHP script. It is used to check for both built-in functions as well as user-defined functions. Syntax: boolean function_exists($function 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 | exit( ) Function The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script. The shutdown functions and object destructors will always be executed even if exit() function is called. The message 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 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 | class_exists() Function 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 h 2 min read PHP property_exists() Function The property_exists() function is an inbuilt function in PHP that is used to check objects and classes have properties or not. Syntax: bool property_exists(object|string $object_or_class, string $property);Parameters: This function accept two parameters that are described below: $object_or_class: Th 2 min read PHP | is_dir( ) Function The is_dir() function in PHP used to check whether the specified file is a directory or not. The name of the file is sent as a parameter to the is_dir() function and it returns True if the file is a directory else it returns False. Syntax: is_dir($file) Parameters Used: The is_dir() function in PHP 1 min read Like