PHP common functions are collected and accompanied by explanatory notes

Source: Internet
Author: User
Tags session id mysql client mysql host natural logarithm php session php database square root symlink
As a PHP programmer, it is necessary to master and memorize some commonly used PHP functions, the following authors will be collected about the array aspects of PHP, PHP system aspects, PHP file processing aspects, PHP string processing, PHP database operations, PHP math and digital processing, and PHP regular aspects of common commonly used functions to do a summary and a simple explanation, no matter when more to see, long time, natural familiar with the heart, the development of the project is also handy, but also hope to help all the vast number of PHP programmers.

(1) PHP array processing common functions

array_change_key_case-returns an array of string key names that are all lowercase or uppercase
array_chunk-splits an array into multiple
Array_combine-creates an array with the value of an array as its key name, and the value of another array as its value
array_count_values-the number of occurrences of all values in the statistics array
array_diff_assoc-with index Check the difference set of the computed array
array_diff_key-Calculating the difference set of an array using the key name comparison
array_diff_uassoc-uses the user-supplied callback function to do an index check to calculate the difference set of the array
array_diff_ukey-using a callback function to compare the difference set of an array to a key name
array_diff-Calculating the difference set of an array
Array_fill_keys-fill an array with values, specifying keys
array_fill-fills an array with the given value
array_filter-filter cells in an array with callback functions
Array_flip-exchanging keys and values in an array
array_intersect_assoc-with index Check the intersection of computed arrays
array_intersect_key-calculating the intersection of an array using the key name comparison
array_intersect_uassoc-with index Check the intersection of computed arrays, using callback function to compare indexes
Array_intersect_ukey-computes the intersection of an array using a callback function to compare the key names
Array_intersect-computes the intersection of an array
array_key_exists-checks whether the given key name or index exists in the array
array_keys-returns all the key names in the array
Array_map-the callback function to the cell of the given array
array_merge_recursive-to merge one or more arrays recursively
array_merge-merging one or more arrays
array_multisort-to sort multiple arrays or multidimensional arrays
Array_pad-fills an array to a specified length with a value
array_pop-pops the last cell of the array (out of the stack)
Array_product-computes the product of all values in an array
array_push-pressing one or more cells into the end of the array (into the stack)
array_rand-random extraction of one or more cells from an array
array_reduce-iteratively to simplify the array to a single value with a callback function
array_reverse-returns an array of cells in reverse order
array_search-searches for the given value in the array, and returns the corresponding key name if successful
Array_shift-moves the cell at the beginning of the array to a group
array_slice-remove a paragraph from an array
array_splice-remove part of the array and replace it with other values
Array_sum-computes the and of all values in the array
array_udiff_assoc-with index Check the difference set of the computed array, using the callback function to compare the data
array_udiff_uassoc-with index Check to calculate the difference of the array, compare the data and index with the callback function
array_udiff-comparing data with callback functions to calculate the difference set of an array
array_uintersect_assoc-with index Check the intersection of the computed array, using the callback function to compare the data
array_uintersect_uassoc-with index Check the intersection of computed arrays, using callback functions to compare data and indexes
Array_uintersect-computes the intersection of an array, compares the data with a callback function
array_unique-duplicate values in an array
array_unshift-inserting one or more cells at the beginning of an array
array_values-returns all values in the array
array_walk_recursive-applying user functions recursively to each member in an array
array_walk-applying user functions to each member in an array
array-creating a new array
arsort-an array in reverse order and maintain an index relationship
asort-sorting an array and maintaining an index relationship
compact-create an array, including the variable names and their values
count-count the number of cells in an array or the number of properties in an object
current-returns the current cell in the array
each-returns the current key/value pair in the array and moves the array pointer forward one step
end-the inner pointer of an array to the last cell
extract-importing variables from an array into the current symbol table
in_array-checks if a value exists in the array
key-getting the key name from the associative array
krsort-an array in reverse order by key name
ksort-sorting arrays by key name
List-assigns the values in the array to some variables
natcasesort-sorting of case-insensitive letters using the "natural sort" algorithm for arrays
natsort-using the "natural sort" algorithm to sort arrays
next-moves the inner pointer in the array forward one
Alias for Pos-current ()
prev-the internal pointer of the array back to a
range-creating an array containing the specified range of cells
reset-the inner pointer of an array to the first cell
rsort-reverse sequence of an array
shuffle-Array is scrambled
Alias for Sizeof-count ()
sort-sorting an array of arrays
uasort-use a user-defined comparison function to sort the values in the array and keep the index associated
uksort-using a user-defined comparison function to sort the key names in an array
usort-using a user-defined comparison function to sort values in an array

(2) php some less common but very practical system-level functions

call_user_method_array-invokes a user method, passing a parameter array (deprecated)
Call_user_method-invoking a user method on a specific object (deprecated)
class_exists-checking whether a class is defined
get_class_methods-returns an array of the method names of the class
get_class_vars-returns an array that consists of the default properties of the class
get_class-returns the class name of the object
get_declared_classes-returns an array consisting of the names of the defined classes
get_declared_interfaces-returns an array containing all the declared interfaces
get_object_vars-returns an associative array consisting of object properties
get_parent_class-returns the parent class name of an object or class
interface_exists-Check if the interface has been defined
is_a-returns TRUE if the object belongs to the class or if the class is the parent class of this object
is_subclass_of-returns TRUE If this object is a subclass of the class
method_exists-checking the existence of a class's methods
property_exists-checking whether an object or class has this property

(3) Common functions of PHP time processing

checkdate-validation of a trellis-high-date
Date_default_timezone_get-Gets the default time zone used by all DateTime functions in a script
date_default_timezone_set-Setting the default time zone for all datetime functions in a script
Date_time_set-sets the time
Date_timezone_get-return time zone relative to given DateTime
Date_timezone_set-sets the time zone for the DateTime object
date-formatting a local time/date
getdate-Get Date/time information
gettimeofday-Get current time
gmdate-formatting a GMT/UTC date/time
gmmktime-UNIX timestamp to get GMT date
gmstrftime-formatting GMT/UTC time/date based on regional settings
idate-to format a local time date as an integer
localtime-Get local time
microtime-returns the current Unix timestamp and number of microseconds
mktime-get a date for Unix timestamp
strftime-formatting local time/date based on regional settings
strptime-parsing date/time generated by strftime ()
strtotime-to parse the datetime description of any English text into a Unix timestamp
time-returns the current Unix timestamp

(4) PHP file system to handle common functions

chdir-Changing directories
chroot-Changing the root directory
Dir-directory class
closedir-Closing a directory handle
Getcwd-get Current working directory
opendir-opening a directory handle
readdir-reading entries from the directory handle
rewinddir-reverse the directory handle
scandir-lists files and directories in the specified path
basename-returns the file name portion of the path
chgrp-changing the group to which the file belongs
chmod-changing the file mode
chown-changing the owner of a file
clearstatcache-clearing the file state cache
copy-Copy Files
delete-See unlink () or unset ()
dirname-returns the directory portion of the path
disk_free_space-returns the free space in the directory
disk_total_space-returns the total disk size of a directory
Alias for Diskfreespace-disk_free_space ()
fclose-Close an open file pointer
feof-Test If the file pointer is at the end of the file
fflush-output buffered content to a file
fgetc-reading characters from the file pointer
Fgetcsv-reads a row from the file pointer and resolves the CSV field
fgets-reading a line from the file pointer
Fgetss-reads a row from the file pointer and filters out HTML tags
file_exists-checking whether a file or directory exists
file_get_contents-to read the entire file into a string
file_put_contents-writing a string to a file
file-to read an entire file into an array
Fileatime-last access time of the file
filectime-Get the Inode modification time of the file
filegroup-get the group of files
fileinode-obtaining the Inode of the file
filemtime-Get File modification time
Fileowner-get the owner of the file
fileperms-permission to obtain a file
filesize-Get File size
filetype-getting the file type
flock-Lightweight consultation document lock-up
fnmatch-matching file name with pattern
fopen-Open File or URL
fpassthru-all remaining data at the output file pointer
fputcsv-format the row as CSV and write the file pointer
Alias for Fputs-fwrite ()
fread-read files (can be used safely in binary files)
fscanf-formatting input from a file
fseek-positioning in the file pointer
fstat-obtaining file information from an open file pointer
ftell-returns the position of the file pointer read/write
ftruncate-truncates a file to a given length
fwrite-writing files (can be used safely in binary files)
glob-looking for file paths that match the pattern
is_dir-determines whether a given file name is a directory
is_executable-to determine if the given file name is executable
is_file-determine if the given file name is a normal file
is_link-determines whether a given file name is a symbolic connection
Is_readable-to determine whether a given file name is readable
is_uploaded_file-to determine if the file was uploaded via HTTP POST
Is_writable-determines whether a given file name can be written
Alias for Is_writeable-is_writable ()
Lchgrp-changes Group Ownership of Symlink
Lchown-changes user ownership of Symlink
link-Establish a hard connection
Linkinfo-get information on a connection
Lstat-gives information about a file or symbolic connection
mkdir-New Directory
Move_uploaded_file-moving uploaded files to a new location
parse_ini_file-parsing a configuration file
pathinfo-return the file path information
pclose-closing Process file pointers
popen-opening a process file pointer
readfile-output a file
readlink-returns the target to which the symbolic connection is pointing
realpath-returns the normalized absolute path name
rename-renaming a file or directory
Rewind-Rewind the position of the file pointer
rmdir-Deleting a directory
Alias for Set_file_buffer-stream_set_write_buffer ()
Stat-give the information of the file
symlink-establishing symbolic connections
tempnam-to create a file with a unique file name
tmpfile-Creating a temporary file
touch-setting file access and modification times
umask-Change the current umask
unlink-Deleting files
mail-sending mail

(5) Mathematical functions and numeric processing functions commonly used in PHP

abs-Absolute Value
acos-Inverse cosine
acosh-Inverse hyperbolic cosine
asin-anyway Chord
asinh-Inverse hyperbolic sine
atan2-two parameters of the inverse tangent
atan-anyway cut
atanh-Inverse hyperbolic tangent
Base_convert-converting numbers between arbitrary binaries
bindec-binary conversion to decimal
Ceil-into one method to take the whole
cos-cosine
cosh-Hyperbolic cosine
decbin-Decimal conversion to Binary
dechex-decimal conversion to hexadecimal
decoct-Decimal conversion to octal
deg2rad-to convert an angle to radians
exp-calculating the exponent of E
The expm1-returns exp (number) –1, and even when the value of # is close to 0, the exact result can be calculated
floor-and rounding out the whole process
fmod-returns the remainder of the floating-point number for division
getrandmax-Displays the maximum possible value of the random number
hexdec-16 binary conversion to decimal
hypot-calculating the length of the hypotenuse of the triangle at all angles
is_finite-to determine whether a finite value
is_infinite-to determine if it is an infinite value
is_nan-determine if the value is legal
lcg_value-Combination Linear congruence generator
log10-logarithm with base 10
log1p-returns log (1 + number), even if the value near 0 can calculate the exact result
log-Natural logarithm
max-Find the maximum value
min-Find the Minimum value
mt_getrandmax-display the maximum possible value of a random number
mt_rand-generate a better random number
mt_srand-sowing a better random number generator seed
octdec-octal conversion to decimal
pi-Get pi Value
pow-exponential expression
rad2deg-convert radians to corresponding number of angles
Rand-produces a random integer
Round-rounding of floating-point numbers
sin-sine
sinh-hyperbolic sine
sqrt-Square Root
srand-sowing random number generator seeds
tan-Tangent
tanh-Hyperbolic tangent

(6) functions commonly used in PHP database operations

Mysql_affected_rows-gets the number of record rows affected by the previous MySQL operation
mysql_change_user-changing the logged-on user in an active connection
mysql_client_encoding-returns the name of the character set
mysql_close-Close MySQL Connection
Mysql_connect-Open a connection to the MySQL server
mysql_create_db-Create a new MySQL database
mysql_data_seek-pointer to move internal result
mysql_db_name-Get Results data
mysql_db_query-Send a MySQL query
mysql_drop_db-Discard (delete) a MySQL database
mysql_errno-returns the numeric encoding of the error message in the previous MySQL operation
mysql_error-returns the text error message from the previous MySQL operation
Mysql_escape_string-escapes a string for mysql_query
Mysql_fetch_array-gets a row from the result set as an associative array, or as a numeric array, or both
mysql_fetch_assoc-getting a row from the result set as an associative array
mysql_fetch_field-to get column information from the result set and return as an object
mysql_fetch_lengths-get the length of each output in the result set
mysql_fetch_object-a row from the result set as an object
mysql_fetch_row-a row from the result set as an enumerated array
Mysql_field_flags-the flags associated with the specified field from the result
mysql_field_len-returns the length of the specified field
mysql_field_name-the field name of the specified field in the result
mysql_field_seek-set the pointer in the result set to the specified field offset
Mysql_field_table-gets the name of the table that contains the specified field
Mysql_field_type-gets the type of the specified field in the result set
mysql_free_result-Releasing result memory
Mysql_get_client_info-Getting MySQL Client information
Mysql_get_host_info-Getting MySQL host information
Mysql_get_proto_info-Get MySQL protocol information
mysql_get_server_info-getting MySQL Server information
Mysql_info-get information about a recent query
Mysql_insert_id-gets the ID generated by the insert operation in the previous step
mysql_list_dbs-list all databases in MySQL server
mysql_list_fields-lists the fields in the MySQL results
mysql_list_processes-List MySQL Process
mysql_list_tables-lists the tables in the MySQL database
Mysql_num_fields-get the number of fields in the result set
Mysql_num_rows-get the number of rows in the result set
mysql_pconnect-open a persistent connection to the MySQL server
Mysql_ping-ping A server connection, reconnect if there is no connection
mysql_query-Send a MySQL query
Mysql_real_escape_string-escapes special characters in strings used in SQL statements, and takes into account the current character set of the connection
mysql_result-Get Results data
mysql_select_db-Select MySQL Database
mysql_stat-getting the current system state
mysql_tablename-Get Table name
Mysql_thread_id-returns the ID of the current thread
Mysql_unbuffered_query-sends a SQL query to MySQL and does not fetch and cache the resulting rows

(7) PHP processing file stream commonly used functions

flush-Refresh Output buffering
Ob_clean-clean (erase) The output buffer
Ob_end_clean-clean (erase) The output buffer and turn off output buffering
Ob_end_flush-flush (send) The output buffer and turn off output buffering
Ob_flush-flush (send) the output buffer
Ob_get_clean-get Current buffer contents and delete current output buffer
Ob_get_contents-return the contents of the output buffer
Ob_get_flush-flush the output buffer, return it as a string and turn off output buffering
Ob_get_length-return the length of the output buffer
Ob_get_level-return The nesting level of the output buffering mechanism
Ob_get_status-get Status of output buffers
Ob_gzhandler-ob_start callback function to gzip output buffer
Ob_implicit_flush-turn implicit flush on/off
Ob_list_handlers-list all output handlers on use
Ob_start-turn on output buffering
Output_add_rewrite_var-add URL rewriter Values
Output_reset_rewrite_vars-reset URL rewriter Values

(8) PHP Regular processing of common functions

preg_grep-returns the array cell that matches the pattern
Preg_last_error-returns the error code of the last PCRE regex execution
preg_match_all-Global Regular expression matching
preg_match-Regular expression matching
Preg_quote-escaping regular expression characters
preg_replace_callback-searching and replacing regular expressions with callback functions
preg_replace-perform search and replace of regular expressions
Preg_split-splitting strings with regular expressions
ereg_replace-Regular Expression substitution
ereg-Regular expression matching
eregi_replace--case-insensitive regular expression substitution
eregi-a case-insensitive regular expression match
Split-using regular expressions to split a string into an array
spliti-to divide a string into an array with regular expressions that are not case-sensitive
Sql_regcase-generating regular expressions for non-differentiated matches

(9) Common functions in PHP session processing

Session_cache_expire-return Current Cache Expire
Session_cache_limiter-get and/or set the current cache limiter
Alias for Session_commit-session_write_close ()
Session_decode-decodes session data from a string
Session_destroy-destroys all data registered to a session
session_encode-encode the current session data as a string
Session_get_cookie_params-get the session cookie parameters
Session_id-get and/or set the current session ID
Session_is_registered-find out whether a global variable was registered in a session
Session_module_name-get and/or set the current session module
Session_name-get and/or set the current session name
Session_regenerate_id-update the current session ID with a newly generated one
Session_register-register one or more global variables with the current session
Session_save_path-get and/or set the current session save path
Session_set_cookie_params-set the session cookie parameters
Session_set_save_handler-sets User-level Session Storage functions
Session_start-initialize Session Data
Session_unregister-unregister a global variable from the current session
Session_unset-free All Session Variables
Session_write_close-write session data and end session

PHP string handling commonly used functions

addcslashes-using backslashes to escape characters in a string in C language style
addslashes-referencing strings with backslashes
bin2hex-converts binary data to hexadecimal notation
Alias for Chop-rtrim ()
chr-returns the specified character
chunk_split-splitting a string into small chunks
count_chars-returns information about the characters used in the string
crc32-computes a crc32 polynomial of a string
Crypt-one-way string encryption (hashing)
Echo-output one or more strings
explode-using one string to split another string
Fprintf-write a formatted string to a stream
Get_html_translation_table-returns the translation table used by Htmlspecialchars () and Htmlentities ()
Hebrev-convert logical Hebrew Text to visual text
Hebrevc-convert logical Hebrew Text to visual text with newline conversion
Html_entity_decode-convert all HTML entities to their applicable characters
Htmlentities-convert all applicable characters to HTML entities
Htmlspecialchars_decode-convert Special HTML entities back to characters
Htmlspecialchars-convert special characters to HTML entities
Implode-join array elements with a string
join-alias Implode ()
Levenshtein-calculate Levenshtein distance between, strings
Localeconv-get Numeric formatting information
Ltrim-strip whitespace (or other characters) from the beginning of a string
Md5_file-calculates the MD5 hash of a given file
Md5-calculate the MD5 hash of a string
Metaphone-calculate the Metaphone key of a string
Money_format-formats a number as a currency string
Nl_langinfo-query Language and locale information
Nl2br-inserts HTML line breaks before all newlines in a string
Number_format-format a number with grouped thousands
Ord-return ASCII value of character
Parse_str-parses the string into variables
Print-output a string
Printf-output a formatted string
Quoted_printable_decode-convert a quoted-printable string to an 8 bit string
Quotemeta-quote Meta characters
Rtrim-strip whitespace (or other characters) from the end of a string
Setlocale-set locale Information
Sha1_file-calculate The SHA1 hash of a file
Sha1-calculate The SHA1 hash of a string
Similar_text-calculate the similarity between and the strings
Soundex-calculate the Soundex key of a string
Sprintf-return a formatted string
Sscanf-parses input from a string according to a format
Str_getcsv-parse a CSV string to an array
Str_ireplace-case-insensitive version of Str_replace ().
Str_pad-pad a string to a certain length with another string
Str_repeat-repeat a string
Str_replace-replace all occurrences of the search string with the replacement string
Str_rot13-perform the rot13 transform on a string
Str_shuffle-randomly shuffles A string
Str_split-convert a string to an array
Str_word_count-return information about words used in a string
Strcasecmp-binary Safe case-insensitive string comparison
strchr-alias Strstr ()
Strcmp-binary Safe string comparison
Strcoll-locale based string comparison
Strcspn-find length of initial segment not matching mask
Strip_tags-strip HTML and PHP tags from a string
Stripcslashes-un-quote string quoted with Addcslashes ()
Stripos-find position of first occurrence of a case-insensitive string
Stripslashes-un-quote string quoted with Addslashes ()
Stristr-case-insensitive strstr ()
Strlen-get string length
Strnatcasecmp-case insensitive string comparisons using a "natural order" algorithm
Strnatcmp-string comparisons using a "natural order" algorithm
Strncasecmp-binary Safe case-insensitive string comparison of the first n characters
Strncmp-binary safe string Comparison of the first n characters
Strpbrk-search a string for any of a set of characters
Strpos-find position of first occurrence of a string
Strrchr-find the last occurrence of a character in a string
Strrev-reverse a string
Strripos-find position of last occurrence of a case-insensitive string in a string
Strrpos-find position of last occurrence of a char in a string
Strspn-find length of initial segment matching mask
Strstr-find first occurrence of a string
Strtok-tokenize string
Strtolower-make a String lowercase
Strtoupper-make A string uppercase
Strtr-translate certain characters
Substr_compare-binary Safe Optionally case insensitive comparison of 2 strings from a offset, up to length characters
Substr_count-count the number of substring occurrences
Substr_replace-replace text within a portion of a string
Substr-return part of a string
Trim-strip whitespace (or other characters) from the beginning and end of a string
Ucfirst-make A string ' s first character uppercase
Ucwords-uppercase the first character of each word in a string
Vfprintf-write a formatted string to a stream
Vprintf-output a formatted string
Vsprintf-return a formatted string
Wordwrap-wraps a string to a given number of characters using a string break character

(one) Some other common functions of PHP

base64_decode-decoding data encoded with MIME base64
base64_encode-encoding data using MIME base64
get_headers-get the server to respond to all headers sent by an HTTP request
get_meta_tags-extracts all meta tags from a file content property, returns an array
http_build_query-the request string after generating Url-encode
parse_url-parse URL, return its components
rawurldecode-decoding encoded URL strings
rawurlencode-encoding URLs according to RFC 1738
urldecode-decoding encoded URL strings
urlencode-encoded URL string
Debug_zval_dump-dumps a string representation of an internal Zend value to output
Alias for Doubleval-floatval ()
empty-checks if a variable is empty
floatval-get the floating-point value of a variable
get_defined_vars-returns an array consisting of all defined variables
get_resource_type-return Resource (Resource) type
Gettype-gets the type of the variable
import_request_variables-importing Get/post/cookie variables into global scope
intval-gets the integer value of the variable
is_array-detecting if a variable is an array
Is_binary-finds whether a variable is a native binary string
is_bool-whether the detection variable is a Boolean type
Is_buffer-finds whether a variable is a native Unicode or binary string
is_callable-detect if the parameter is a legitimate callable structure
Alias for Is_double-is_float ()
is_float-detect if the variable is floating-point
is_int-detect if the variable is an integer
Alias for Is_integer-is_int ()
Alias for Is_long-is_int ()
is_null-Detecting if the variable is null
is_numeric-detect if a variable is a numeric or numeric string
is_object-detects if a variable is an object
Alias for Is_real-is_float ()
is_resource-detecting if a variable is a resource type
is_scalar-whether the detection variable is a scalar
is_string-detecting if a variable is a string
Is_unicode-finds whether a variable is a Unicode string
isset-detect if the variable is set
print_r-prints easy-to-understand information about variables.
Serialize-produces a representation of a value that can be stored
settype-setting the type of a variable
Strval-gets the string value of the variable
unserialize-to create a PHP value from a stored representation
Unset-releasing the given variable
var_dump-information about the print variable
Var_export-the string representation of the output or return of a variable

  • 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.