PHP uses function_exists to determine how the function is available, phpfunction_exists_php tutorial

Source: Internet
Author: User
Tags imagejpeg php server

PHP uses function_exists to determine how the function is available, phpfunction_exists


The examples in this paper describe the methods that PHP uses to determine the Function_exists function. Share to everyone for your reference. Specific as follows:

The function described in this article is used to create a GIF format graphics, parameters im for the use of Imagecreate () created by the image code, parameter filename can be omitted, if there is no this parameter filename, will be sent directly to the browser side, remember to send out the image before the use of Content-type:image/gif the header string (header) to the browser side to smooth the transfer of the picture. To use a transparent background gif, which is the gif89a format, you need to first configure the transparent background with imagecolortransparent ().
Copy CodeThe code is as follows: $values =array (
40,50,//coordinates of the first vertex
20,240,//coordinates of the first vertex
60,60,//coordinates of the first vertex
240,20,//coordinates of the first vertex
50,40,//coordinates of the first vertex
10,10//coordinates of the first vertex
);
$im =imagecreatetruecolor (250,250); Create an image
$BG =imagecolorallocate ($im, 200,200,200); Define a gray background
$yellow =imagecolorallocate ($im, 255,255,0); Define yellow foreground
Imagefilledpolygon ($im, $values, 6, $yellow); Draw a polygon
Header (' content-type:image/png ');
Determine if GIF function exists
if (function_exists ("Imagegif"))
{
If present, output in GIF format
Header ("Content-type:image/gif");
Imagegif ($im);
}
Determine if the JPEG function exists
ElseIf (function_exists ("imagejpeg"))
{
If present, output in JPG format
Header ("Content-type:image/jpeg");
Imagejpeg ($im, "", 0.5);
}
Determine if the PNG function exists
ElseIf (function_exists ("Imagepng"))
{
If present, output in PNG format
Header ("Content-type:image/png");
Imagepng ($im);
}
Determine if the Wbmp function exists
ElseIf (function_exists ("Imagewbmp"))
{
If present, output in BMP format
Header ("Content-type:image/vnd.wap.wbmp");
The header () function sends the original HTTP header to the client, recognizing that it is important to call the header () function before any actual output is sent (in PHP 4 and later, you can use output caching to resolve this issue):
Copy CodeThe code is as follows: Imagewbmp ($im);
}
Else
{
If neither is supported, the output content
Die ("No image, support in this PHP server");
}

The code determines multiple image support, and then prints the image in the appropriate format.

Syntax: int imagegif (int im, string [filename]);

Return value: Integer, Function type: graphics processing

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/914050.html www.bkjia.com true http://www.bkjia.com/PHPjc/914050.html techarticle PHP uses function_exists to determine how the function is available, and phpfunction_exists This example describes the methods available for PHP to use the Function_exists judgment function. Share to everyone for your reference. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.