Php knowledge point summary

Source: Internet
Author: User
Php knowledge point summary? Php knowledge point summary :? 1. get the data submitted by the client $ _ POST [];? $ Str = $ _ POST ['name']; 2. implement the intersection of two arrays, and the difference function :?? Array_intersect ($ array1, $ array2); (intersection of php knowledge points)

?

Php knowledge point summary:

?

1. get the data submitted by the client $ _ POST [];

? ? $ Str = $ _ POST ['name'];

2. implement the intersection of two arrays, and the difference function:

? ? Array_intersect ($ array1, $ array2); (intersection function)

? ? Array_diff ($ array1, $ array2); (difference set function)

? ? Array_merge ($ array1, $ array2); (Union function)

3. function for outputting array elements:

? ? $ Fruit = array ("lemon", "orange", "banana ");

? ? Print_r ($ fruit );

Result: Array ([0] => lemon [1] => orange [2] => banana );

4. array sorting:

?

"; Print_r ($ array); // echo implode ("-", $ array); sort ($ array); echo"
After sorting arrays
"; Foreach ($ array as $ key => $ val) {echo" array [". $ key."] = ". $ val ."
";}?>

 

?

? Output result:

?

Array ([0] => asp [1] => php [2] => jsp) before Array sorting) array [0] = asp array [1] = jsp array [2] = php

 

? Red, keys and values in the php array

5. file reading

? ? The EOF character, which is usually called the end of a file or the EOF character, is used by php programs to identify when the object ends.

? ? The feof () function is used to determine whether the file is at the end. the fgets () function reads a row of files at a time. the fscanf () function provides a method for parsing files in the specified format, the fseek (resource handle, int offset [, int whence]) function can be used to randomly extract file rows.

6. obtain functions of file, directory, and disk size

? ? The filesize (string filename) function is used to return the number of bytes of a file. However, unexpected results may occur when the file is larger than 2 GB. sprintf ("% u ", filesize ($ file)

7. file Upload

? ? By using the Global Array $ _ FILES of PHP, you can upload FILES from the client's computer to a remote server.

?

$ _ FILES ["file"] ["name"]-name of the file to be uploaded $ _ FILES ["file"] ["type"]-type of the file to be uploaded $ _ FILES ["file"] ["size"]-size of the uploaded file, in bytes $ _ FILES ["file"] ["tmp_name"]-name of the temporary copy of the file stored on the server $ _ FILES ["file"] ["error"] -error code caused by file upload

 

? 8. obtain the image size.

?

Array getimagesize (string $ filename [, array & $ imageinfo])

 

?

?

?

?

?

9. get the time. you can use time (), date (), getdate ()-to get the date/time information,

?

 

? The returned value is

?

Now: 2005-03-30 Next Week: 2005-04-07

 

? 10. the header () function sends the original HTTP header to the client.Note:: No other output is allowed before the packet header is sent. Otherwise, an error is returned?

You are prompted to save a generated PDF file (the Content-Disposition header is used to provide a recommended file name and force the browser to display the save dialog box ):

 

11. several common functions for database operations

? ? Mysql_connect ("localhost", "root", "root ");

? ? Mysql_fetch_object? -? Retrieve a row from the result set as an object

? ? Mysql_query ("set names 'gbk '");

?

?

? 12. use & connection to transmit multiple parameters in php. for example:

var url="sort_1.php?px="+px+"&px2="+px2; 

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

Getimagesize ()? The function will determine any? GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM? Or? WBMP? The size of the image file and the size of the returned image, the file type, and a common? HTML? File?IMG? The height/width text string in the flag.

If not?Filename? The specified image or the image is not valid,Getimagesize ()? Will return?FALSE? And generate one?E_WARNING? Level errors

?

Returns an array with four units. Index 0 contains the pixel value of the image width, and index 1 contains the pixel value of the image height. Index 2 is the mark of the image type: 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. These tags correspond to the newly added IMAGETYPE constant in PHP 4.3.0. Index 3 is a text string with the content "height =" yyy "width =" xxx "and can be directly used for IMG marking.

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.