Home  >  Article  >  Backend Development  >  How to check if a function exists in php

How to check if a function exists in php

王林
王林Original
2020-08-13 13:44:062916browse

How to check whether a function exists in php: You can use the function_exists() function to judge. Returns true if the function exists, false otherwise. The specific usage method is: [function_exists('curl_init')].

How to check if a function exists in php

The function_exists() function determines whether the given function has been defined. If function_name exists and is indeed a function, it returns TRUE , otherwise it returns FALSE .

(Recommended tutorial: php graphic tutorial)

Syntax:

function_exists ( string $function_name ) : bool

Note: function_name must be a string.

(Video tutorial recommendation: php video tutorial)

Code implementation:

if(function_exists('curl_init')){
    curl_init();
}else{    
    echo 'not function curl_init';
}

The above is the detailed content of How to check if a function exists in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn