Common php system functions and php Functions

Source: Internet
Author: User

Common php system functions and php Functions

String Functions

Strlen: Get the string length, in bytes

Substr: String truncation. Obtain the string (in bytes)

Strchr: similar to substr, It is intercepted from the specified position until the end.

Strrchr (get file suffix): Same as strchr, it only looks for characters from the right

Strtolower: All characters are in lower case (for English letters)

Strtoupper: All characters are capitalized.

Strrev: String inversion (only reverse English: Only one byte is stored in English). Reverse by byte

Strpos: Find the position of the corresponding character in the string (numeric subscript), start from the leftmost

Strrpos: Same as strpos, It is found from the right side of the string.

Trim: remove the characters on both sides of the function. The default value is space.

Time and date functions

Time: returns the timestamp of the current time (INTEGER: Starting from 00:00:00 GMT, January 1, January 1, 1970 ).

Date: Time serialization function, which converts the specified timestamp to the display format of the specified time date (random string: subject to professional format characters). If no timestamp is specified, the system uses the timestamp of the current time by default.

Strtotime: converts a string in the time and date format to a corresponding timestamp. (if it is a correct time expression, it can be converted)

Microtime: microsecond timestamp. Different results are returned based on different requirements, mixed microtime (Boolean Type). A floating point time or an array (Timestamp and number of microseconds) can be returned)

Mathematical functions

Abs: absolute value

Floor: The result of the entire floor (3.2) down is 3.

Ceil: rounded up

Round: Rounding

Rand: returns a random integer in the specified range.

Mt_rand: Get a random integer in the specified range (more efficient)

Array Functions

Key: Obtain the subscript of the element pointed to by the current pointer of the current array.

Current: obtains the value of the current pointer pointing to the element.

Next: Get the value of the next element and move the pointer down

Prev: Get the value of the previous element and move the pointer up

End: Move the pointer to the last element of the array and return the value of the final pointer position.

Reset: Move the pointer to the first element of the array and return the value of the final pointer position.

Array_keys: obtains all key names of an array and returns an index array.

Array_values: obtains all values of an array and returns an index array.

Explode: explosion. A string is divided into multiple segments according to a specified rule (usually a special character). Each segment is treated as an array element and an index array is returned.

Implode: bond, concatenates all elements in an array into a string according to a specified rule (special character ).

Array_merge: merge, which means to accumulate the elements in the two arrays. If the following array has the same subscript (key name: Join) as the preceding array, the value of the following element overwrites the previous one. If the index has the same subscript, the subscript is automatically modified and superimposed into the previous array.

Data structure simulation functions

Array_shift: displays elements from the front of the array to obtain the element value.

Array_pop: Elements popped up after the array to obtain the element value.

Array_unshift: press an element from the front of the array to obtain the number of elements in the current array.

Array_push: press an element from the back of the array to obtain the number of elements in the current array.

Variable judgment

Is_bool: determines whether it is a boolean type.

Is_float: determines the floating point type

Is_integer: determines the integer type.

Is_object: Judgment object

Is_array: determines the Array

Is_string: Judge the string

Is_resource: determine the resource

Is_scalar: scalar is a scalar. It determines the basic data type: integer, floating point, Boolean, and string.

Is_null: whether it is null

Is_numeric: A string composed of numbers or pure numbers.

Gettype: Get Data Type

Settype: Change the Data Type

File Operation Functions

Opendir (PATH): open a path Resource (read all data in the path to the memory)

Readdir (path Resource): Read the name of the file pointed to by the current resource pointer from the folder resource, and the pointer will move one bit down

Closedir (Resource): releases the corresponding file resource

Scandir: reads all file names in a path and returns an array. Each element of the array is a file name.

File_exists: determines whether a file exists (in a broad sense: path and file)

Is_dir: determines whether a specified path exists (folder)

Is_file: determines whether a specified path is a file)

Mkdir: create a path. If the path exists, an error is returned.

Rmdir: Remove a folder

File_get_contents: reads data from a specified file.

File_put_contents: writes the specified string to the corresponding file.

Fopen: open a file resource

Fgetc: c Represents character. One character is read at a time.

Fgets: s indicates string, which indicates that multiple characters can be read, depending on the specified read length or whether a line break occurs (a maximum of one row of data can be read)

Both functions operate on the current resource pointer, And the pointer will be moved down after reading

Fread: obtains data of the specified length until the end of the file.

Fwrite: write data to the location where the file resource pointer is located. Writing will not move the existing content in the current location back, but will overwrite

Fseek: Specifies the pointer to the corresponding position.

Fclose: Use the corresponding file resource

Copy: copy

Unlink: delete an object

Rename: rename a file

Filemtime: m indicates modify. The last modification time of the file.

Filesize: file size (in bytes)

Fileperms: File Permission (octal in Linux)

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

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.