PHP method_exists() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 parameters that are described below: $object_or_class: It contains the name of the object or class.method: It contains the name of the method.Return Value: This method returns "true" if the class method exists in a given object or class, and false otherwise. Example 1: In this example, we will check method_exists() in a given class or object, if not exists it will return "true". PHP <?php $directory = new Directory('.') ; var_dump(method_exists($directory,'read')); ?> Output: bool(true);Example 2: In this example, we will check for "redirect" in method_exists() in a given class or object, if not it will return "false". PHP <?php $directory = new Directory('.') ; var_dump(method_exists($directory,'redirect')); ?> Output: bool(false); Reference: https://www.php.net/manual/en/function.method-exists.php Comment More infoAdvertise with us Next Article PHP | function_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 | 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 interface_exists() Function 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. 1 min read Like