PHP requires divergent thinking. I think that in the course of learning, everyone needs to know how to play and make a sense of accomplishment. In that case, the learning effect and enthusiasm will be very high and they will like what they learn more! For example, I think that in the course of learning, you need to know how to play and make a sense of accomplishment. In that case, the learning effect and enthusiasm will be very high,
You will enjoy your learning!
Example:
Today, I learned several functions from the image function section of PHP:
Getimagesize ()
Array getimagesize (string $ filename [, array & $ imageinfo])
The getimagesize () function will determine any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, the size of the XBM or WBMP image file, the size of the returned image, the file type, and a height/width text string that can be used in the IMG mark of a common HTML file.
Imagecreatefromgif ()
Resource imagecreatefromgif (string $ filename)
Imagecreatefromgif () returns an image identifier, representing the image obtained from the given file name.
This function returns an operation handle to make it easier to use this image resource.
Similar functions include imagecreatefromjpeg () and imagecreatefrompng (). you can refer to the official online manual.
Imagecolorat ()
Int imagecolorat (resource $ image, int $ x, int $ y)
Returns the color index value of the specified position pixel in the image.
Imagecolorsforindex ()
Array imagecolorsforindex (resource $ image, int $ index)
This function returns an associated array with key names of red, green, blue, and alpha, containing the corresponding values of the specified color index.
You have read a rough introduction and it is estimated that you are sleepy, but please stick to it!
So how can I practice these functions?
Actually, when I learned these functions, I immediately thought of a very interesting thing to do!
What is it? You can guess ~!!!!
Check the code:
$ Url = "logo-yy.gif ";
$ Size = getimagesize ($ url );
$ Width = $ size [0];
$ Height = $ size [1];
$ Im = imagecreatefromgif ($ url );
For ($ y = 1; $ y <$ height; $ y ++ ){
For ($ x = 1; $ x <$ width; $ x ++ ){
$ Color_index = imagecolorat ($ im, $ x, $ y );
$ Color_tran = imagecolorsforindex ($ im, $ color_index );
Echo ("");
Echo ("love ");
Echo ("");
}
Echo ("
");
}
?>
Note that the function used in my program is imagecreatefromgif ()
Therefore, the $ url variable points to a file in GIF format. to point to a file in JPG format, use imagecreatefromjpeg ()
Of course, we can write it together, because the first function can determine the image format. I will not write it here !! Haha
Now, you have a php environment and try something! Haha
We do not recommend using too many images! Just a small logo!
Otherwise, don't blame me for not telling you!
This example is useless !! However, it can stimulate everyone's learning pleasure !!
To those who are learning PHP!
The effect and enthusiasm of NLP learning will be very high, and you will prefer what you learn! Example...