Common system functions for PHP

Source: Internet
Author: User

common system functions for PHPThis article introduced the PHP commonly used system function, has the very good reference value, follows with the big treasure son to see together below String Functions strlen (): Gets the string length, byte length

substr (): String intercept, get string (intercept by byte)

STRCHR (): Similar to substr, intercept from a specified position until the last

STRRCHR (get file suffix name): As with STRCHR, just start looking for characters from the right

Strtolower (): All characters are lowercase (for the English alphabet)

Strtoupper (): All characters are capitalized

Strrev (): String reversal (can only be reversed in English: only one byte in English storage), reversed by byte

Strpos (): Find the position of the corresponding character (digital subscript) from the string, and start at the far left.

Strrpos (): As with Strpos, just start looking from the right side of the string

Trim (): Remove the characters from both sides of the function, and the default is a space

Time-Date function

Time (): Gets the timestamp of the current time (int: Starting from GMT January 1, 1970 0:0 0 seconds) Number of seconds

Date (): A time-serialization function that converts the specified timestamp to the display format of a given time date (random string: A professional format specifier), and if no timestamp is specified, the system defaults to the timestamp of the current time

Strtotime (): The time-date format string is converted to the corresponding timestamp (as long as the correct English time expression is used, it can be converted)

Microtime (): microsecond timestamp, returns different results according to different requirements mixed Microtime (Boolean type), can return a floating-point number of time, can also return an array (timestamp and number of microseconds)

Math-related functions

ABS: Absolute Value

Floor: down to floor (3.2) result equals 3

Ceil: Rounding up

Round: Rounding

Rand: Gets a random integer within the specified range

Mt_rand: Gets a random integer within a specified range (more efficient)

array-related functions

Key: Gets the subscript of the element to which the current pointer is pointing

Current: Gets the value of the currently pointing pointer to the element

Next: Gets the value of the next element and moves the pointer down

Prev: Gets the value of the previous element and moves the pointer up

End: Moves the pointer to the last element of the array and returns the value of the final pointer position

Reset: Moves the pointer to the first element of the array, returning the value of the final pointer position

Array_keys: Gets all the key names of an array, returning an indexed array

Array_values: Gets all the values of an array, returning an indexed array

Explode: Explode, a string in accordance with a specified rule (usually a special character), the array is divided into multiple segments, each paragraph as an element of an array, return an indexed array

Implode: Glue all elements inside an array into a single string, according to a specified rule (special character)

Array_merge: Merge, which refers to the accumulation of elements in two arrays. If the following array has the same subscript (Key Name: Association) as the previous array, then the values of the subsequent elements will be overwritten, and if the index is the same subscript, the subscript will be automatically modified to overlay the preceding array.

data structure Simulation function

Array_shift: POPs the element from the front of the array to get the value of the element

Array_pop: POPs the element from the back of the array to get the value of the element

Array_unshift: Pressing elements from the front of the array to get the number of elements in the current array

Array_push: Pressing elements from the back of an array to get the number of elements in the current array

Judging Variables

Is_bool: Judging whether it is a Boolean type

Is_float: Judging floating-point type

Is_integer: Judging the integral type

Is_object: Judging objects

Is_array: Judging arrays

Is_string: Judging string

Is_resource: Judging Resources

Is_scalar:scalar is scalar, and judgment is the basic data type: Integer, Float, Boolean and string

Is_null: Is empty

Is_numeric: A string that determines a number or a pure number

GetType: Getting Data types

Settype: Changing the data type

File manipulation Functions

Opendir (PATH): Opens a path resource (reads all the data inside the path into memory)

Readdir (Path Resource): reads the name of the file pointed to by the current resource pointer from the folder resource, and the pointer moves down one

Closedir (Resource): Release the corresponding file resource

Scandir (PATH): reads all the file names inside a path, returns an array, and each element of the array is a file name.

File_exists: Determine if a file exists (file is generalized: path and file)

Is_dir: Determines whether a specified path exists (folder)

Is_file: Determines whether a specified path is a file (file)

mkdir: Create a path that will cause an error if the path exists

RmDir: Removing folders

File_get_contents: Reads the contents of the data from within a specified file.

File_put_contents: Writes the specified string to the corresponding file

fopen: Opening a file resource

FGETC:C represents character, reading one character at a time

Fgets:s represents a string, which means that multiple characters can be read, depending on the specified read length or whether a newline is encountered (up to one row of data)

All two functions operate on the current resource pointer and move the pointer down after reading

Fread: Gets data of the specified length until the end of the file

Fwrite: Writes data to the location where the file resource pointer is located, writing does not move things that are already in the current position, but overwrites

Fseek: Assigning pointers to the corresponding positions

Fclose: Using the corresponding file resource

Copy: Copying

Unlink: Deleting files

Rename: Renaming files

Filemtime:m represents modify, the last time the file was modified

FileSize: File Size (bytes)

Fileperms: File permissions (octal under Linux)

(Note: This article is organized by Wang Zhilei , reproduced please indicate the source.) )

Common system functions for PHP

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.