Home >Backend Development >PHP Tutorial >php learning, 2016-5-10 2016 party members learning experience 2016 two sessions spirit learning experience 2016 two sessions spirit learning experience

php learning, 2016-5-10 2016 party members learning experience 2016 two sessions spirit learning experience 2016 two sessions spirit learning experience

WBOY
WBOYOriginal
2016-07-29 08:49:511429browse

1. bool function_exists (string $function_name)

Find function_name in the list of defined functions (including system-built-in functions and user-defined functions).

  • Returns: If a function has been defined, return true
  • For syntax structure query, return false

2. bool imagefilter ( resource sr cim,intfiltertype [, int arg 1[,intarg2 [, int $arg3 ]]] ) Use filters on images php5,7

imagefilter() Apply the filter filtertype to the image, using arg1, arg2 and arg3 as needed.
This function is only available in PHP versions compiled with the GD library.

  • filtertype can be one of the following:

    • IMG_FILTER_NEGATE: Invert all colors in the image.
    • IMG_FILTER_GRAYSCALE: Convert the image to grayscale.
    • IMG_FILTER_BRIGHTNESS: Change the brightness of the image. Use arg1 to set the brightness level.
    • IMG_FILTER_CONTRAST: Change the contrast of the image. Use arg1 to set the contrast level.
    • IMG_FILTER_COLORIZE: Similar to IMG_FILTER_GRAYSCALE, but the color can be specified. Use arg1, arg2 and arg3 to specify red, blue and green respectively. Each color range is 0 to 255.
    • IMG_FILTER_EDGEDETECT: Use edge detection to highlight the edges of the image.
    • IMG_FILTER_EMBOSS: Make the image embossed.
    • IMG_FILTER_GAUSSIAN_BLUR: Blur the image using Gaussian algorithm.
    • IMG_FILTER_SELECTIVE_BLUR: Blur the image.
    • IMG_FILTER_MEAN_REMOVAL: Use the average removal method to achieve the contour effect.
    • IMG_FILTER_SMOOTH: Make the image smoother. Use arg1 to set the smoothness level.
<code><span><?php</span><span>$im</span> = imagecreatefrompng(<span>'dave.png'</span>);
<span>if</span> (<span>$im</span> && imagefilter(<span>$im</span>, IMG_FILTER_GRAYSCALE)) {
   <span>echo</span><span>'图片转化为灰度成功'</span>;
   imagepng(<span>$im</span>, <span>'dave.png'</span>);
} <span>else</span> {
   <span>echo</span><span>'图片转化为灰度失败'</span>;
}

imagedestroy(<span>$im</span>);
<span>?></span></code>
  • If the format of the imagecreatefrompng() function does not match the actual image, the mismatch here is the original format, not the modified extension
  • If there is a mismatch, the error message is: gd-jpeg : JPEG library reports unrecoverable error
  • Query the information of an image getimagesize()

3.array getimagesize ( string $filename )

** This function contains an optional parameter, and official information is ignored because it is not commonly used

getimagesize() function will determine the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM or WBMP image file and return the image dimensions and file type and a height/width text string that can be used in IMG tags in normal HTML files.

<code>print_r(getimagesize(<span>"web.jpg"</span>));
<span>/*
输出:
Array
(
    [0] => 568 图像宽度的像素值
    [1] => 2628 图像高度的像素值
    [2] => 1 图像类型  
    [3] => width="568" height="2628"  图片长宽字符串
    [bits] => 8 每种颜色的位数
    [channels] => 3 对于 RGB 图像其值为 3,对于 CMYK 图像其值为 4
    [mime] => image/gif 该图像的 MIME 类型
)
*/</span></code>

Tags for image types: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order ), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM.

4.resource imagecreatefromgd2 ( string $filename ) Create a new image from a GD2 file or URL


Questions left

  1. imagecreatefromgd2()

    If the fopen wrapper is enabled, in this function, the URL can be used as file name. See fopen() for details on how to specify a file name. For the different functions of various wappers, please refer to the supported protocols and encapsulation protocols, pay attention to their usage and the predefined variables they can provide.

    • url means that you can select a non-gd2 format image, but I tried and it didn’t work
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces PHP learning, 2016-5-10, including PHP learning, 2016 content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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