Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How the function_exists function defines the use of the

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report