How to check if a function exists in php

王林
Release: 2023-03-04 12:34:01
Original
2976 people have browsed it

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
Copy after login

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';
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template