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 N 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 Like