Get the App
SLTechnology News&Howtos  ›  Development  › 

How the function_exists function defines the use of the

Shulou Source: shulou.com Published: 2022-06-03 11:02:44 10月16日 Update

This article mainly introduces how to define the use of function_exists function, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Function_exists is a function used to check whether the specified function has been defined.

Definition and usage of function_exists

Booleanfunction_exists (stringfunction_name), this function is used to check whether the specified function has been defined. The parameter function_name is the name of the function to be checked. Returns a value of 1 if the specified function is defined, and a value of 0 in all other cases.

Grammar editing

Function_exists (stringfunction_name)

Parameters.

explain

Function_name

Necessary. Is the name of the function to be checked.

Example editing

The output is as follows:

The phpinfo () function has been defined

Function_exists instance

/ / determine whether the gif function exists

If (function_exists ("imagegif"))

{

/ / if it exists, output in gif format

Header ("content-type:image/gif")

Imagegif ($im)

}

/ / determine whether the jpeg function exists

Elseif (function_exists ("imagejpeg"))

{

/ / if it exists, output in jpg format

Header ("content-type:image/jpeg")

Imagejpeg ($im, ", 0.5)

}

/ / determine whether the png function exists

Elseif (function_exists ("imagepng"))

{

/ / if it exists, output in png format

Header ("content-type:image/png")

Imagepng ($im)

}

/ / determine whether the wbmp function exists

Elseif (function_exists ("imagewbmp"))

{

/ / if it exists, output in bmp format

Header ("content-type:image/vnd.wap.wbmp")

/ *

The header () function sends the original http header to the client.

It is important to realize that the header () function must be called before any actual output is sent (in php4 and later, you can use output caching to resolve this problem):

* /

Imagewbmp ($im)

}

Else

{

/ / if neither is supported, output the content

Die ("noimagesupportinthisphpserver")

}

Thank you for reading this article carefully. I hope the article "how to define the use of function_exists function" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Function output format article check parameter name support original important value example interest content at the same time instance actual client client situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Apple MySQL Shulou Technology