Php function_exists judgment function available code

Source: Internet
Author: User

Function_exists can be used to determine whether the parameters in the php tutorial. ini file are enabled. For example, if the gd library is enabled in the preparation file
*/
$ Values = array (
40, 50, // coordinates of the first Vertex
20,240, // coordinates of the first Vertex
60, 60, // coordinates of the first Vertex
, 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); // defines the gray background
$ Yellow = imagecolorallocate ($ im, 255,255, 0); // defines the yellow foreground
Imagefilledpolygon ($ im, $ values, 6, $ yellow); // draw a polygon
Header ('content-type: image/png ');
// Determine whether the gif function exists
If (function_exists ("imagegif "))
{
// If yes, output in gif format
Header ("content-type: image/gif ");
Imagegif ($ im );
}
// Determine whether the jpeg function exists
Elseif (function_exists ("imagejpeg "))
{
// If yes, output in jpg format
Header ("content-type: image/jpeg ");
Imagejpeg ($ im, "", 0.5 );
}
// Determine whether the png function exists
Elseif (function_exists ("imagepng "))
{
// If yes, output in png format
Header ("content-type: image/png ");
Imagepng ($ im );
}
// Determine whether the wbmp function exists
Elseif (function_exists ("imagewbmp "))
{
// If yes, 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 php 4 and later versions, you can use the output cache to solve this problem):


*/
Imagewbmp ($ im );
}
Else
{
// Output content if none of them are supported
Die ("no image support in this php server ");
}
/*
The code execution result is similar to that of code 22-25.
The difference is that the Code identifies multiple types of image support and then outputs the image in the corresponding format.

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

Return Value: integer

Function Type: Graphic Processing


 
 
Description


This function is used to create a gif image. The im parameter is the Image Code created using imagecreate. The filename parameter can be omitted. If filename is not specified, the image is sent to the browser. Remember to use content-type before sending the image: the header string of the image/gif is sent to the browser to transmit the image smoothly. To use a gif image with a transparent background, that is, the gif89a format, you must first use imagecolortransparent () to configure a transparent background. The gif image generated by this function is copyrighted.

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.