As a PHP programmer, it is necessary to master and memorize some commonly used PHP functions. Below, the author will collect information about PHP arrays, PHP systems, PHP file processing, PHP string processing, and PHP database operations. , PHP mathematics and number processing, as well as PHP regular functions are summarized and attached with simple instructions. Take a look at them when you have nothing to do. Over time, you will naturally become familiar with them, and you will be able to develop projects with ease. At the same time, I also hope to help all PHP programmers.
(1) Commonly used functions for php array processing
array_change_key_case — Returns an array with all string keys in lowercase or uppercase
array_chunk — Splits an array into multiple
array_combine — Creates an array with the value of one array as its key and the value of another array as its value
array_count_values — Count the number of occurrences of all values in an array
array_diff_assoc — Calculate the difference of an array with index checking
array_diff_key — Calculate the difference of an array using key name comparison
array_diff_uassoc — Calculate an array with an index check using a user-provided callback function
array_diff_ukey — Calculate the difference of an array using a callback function to compare keys
array_diff — Calculate the difference of an array
array_fill_keys — Fill an array with values, specifying keys
array_fill — Fill an array with the given values
array_filter — Use a callback function to filter elements in an array
array_flip — Swap keys and values in an array
array_intersect_assoc — Compute the intersection of arrays with index checking
array_intersect_key — Compute the intersection of arrays using key name comparison
array_intersect_uassoc — Compute the intersection of arrays with index checking, Use callback function to compare indexes
array_intersect_ukey — Use callback function to compare keys to calculate the intersection of arrays
array_intersect — Calculate the intersection of arrays
array_key_exists — Check if the given key or index exists in the array
array_keys — Return all keys in the array Key name
array_map — Apply a callback function to the cells of the given array
array_merge_recursive — Recursively merge one or more arrays
array_merge — Merge one or more arrays
array_multisort — Sort multiple arrays or multidimensional arrays
array_pad — Pad the array to the specified length with values
array_pop — Pop the last element of the array (pop)
array_product — Calculate the product of all values in the array
array_push — Push one or more elements to the end of the array (push)
array_rand — Randomly extract one or more cells from an array
array_reduce — Use a callback function to iteratively reduce an array to a single value
array_reverse — Return an array with cells in reverse order
array_search — Search an array for a given value, If successful, return the corresponding key name
array_shift — Move the beginning of the array out of the array
array_slice — Remove a section from the array
array_splice — Remove a part of the array and replace it with other values
array_sum — Calculate the sum of all values in the array
array_udiff_assoc — Computes the difference of an array with an index check, and uses a callback function to compare the data
array_udiff_uassoc — Computes the difference of an array with an index check, and uses a callback function to compare the data and index
array_udiff — Use a callback function to compare the data to calculate the difference of an array
array_uintersect_assoc — Calculate the intersection of arrays with index checking, compare the data with a callback function
array_uintersect_uassoc — Calculate the intersection of arrays with index checking, compare the data and indexes with a callback function
array_uintersect — Calculate the intersection of arrays, compare the data with a callback function
array_unique — Shift Remove duplicate values in an array
array_unshift — Insert one or more cells at the beginning of the array
array_values — Return all values in the array
array_walk_recursive — Recursively apply a user function to each member of the array
array_walk — Apply each element in the array Apply user functions to members
array — Create a new array
arsort — Sort the array in reverse and maintain the index relationship
asort — Sort the array and maintain the index relationship
compact — Create an array, including variable names and their values
count — Count the number of elements in an array or the number of attributes in an object
current — Returns the current element in the array
each — Returns the current key/value pair in the array and moves the array pointer forward one step
end — Moves the array’s internal pointer Points to the last cell
extract — Import variables from the array into the current symbol table
in_array — Check whether a certain value exists in the array
key — Get the key name from the associative array
krsort — Reverse sort the array by key name
ksort — Sort an array by key name
list — Assign the values in the array to some variables
natcasesort — Use the “natural sort” algorithm to sort the array in a case-insensitive manner
natsort — Use the “natural sort” algorithm to sort the array Sort
next — Move the internal pointer in the array forward by one
pos — Alias for current()
prev — Move the internal pointer of the array back by one
range — Create an array containing the specified range of cells
reset — Set The internal pointer of the array points to the first element
rsort — Sort the array in reverse order
shuffle — Shuffle the array
sizeof — Alias for count()
sort — Sort the array
uasort — Use a user-defined comparison function to sort the array Sort the values and keep the index association
uksort — Use a user-defined comparison function to sort the key names in the array
usor — Use a user-defined comparison function to sort the values in the array
(2) php some Less commonly used but very useful system-level functions
call_user_method_array — Call a user method, passing an array of parameters (deprecated)
call_user_method — Call a user method on a specific object (deprecated)
class_exists — Check whether the class is defined
get_class_methods — Return an array of method names of the class
get_class_vars — Returns an array consisting of the default attributes 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 declared interfaces
get_object_vars — Returns the Associative array of object attributes
get_parent_class — Returns the parent class name of the object or class
interface_exists — Checks whether the interface has been defined
is_a — Returns TRUE if the object belongs to this class or this class is the parent class of this object
is_subclass_of — If If this object is a subclass of this class, TRUE is returned
method_exists — Check whether the method of the class exists
property_exists — Check whether the object or class has this property
(3) Commonly used functions for PHP time processing
checkdate — Verify a grid Ligaoli Date
date_default_timezone_get — Get the default time zone used by all date and time functions in a script
date_default_timezone_set — Set the default time zone used by all date and time 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 — Format a local time/date
getdate — Get date/time information
gettimeofday — Get the current time
gmdate — Format a GMT/UTC date/time
gmmktime — Get the UNIX timestamp of a GMT date
gmstrftime — Format a GMT/UTC time/date according to the locale
idate — Format the local time date as an integer
localtime — Get the local time
microtime — Return the current Unix timestamp and Number of microseconds
mktime — Get the Unix timestamp of a date
strftime — Format the local time/date according to the locale
strptime — Parse the date/time generated by strftime()
strtotime — Parse the datetime description of any English text For Unix timestamp
time — returns the current Unix timestamp
(4) Commonly used functions for php file system processing
chdir — change directory
chroot — change root directory
dir — directory class
closedir — close directory handle
getcwd — get current working directory
opendir — open directory handle
readdir — read entries from directory handle
rewinddir — rewind Directory handle
scandir — List files and directories in a specified path
basename — Return the filename portion of a path
chgrp — Change the group a file belongs to
chmod — Change the file mode
chown — Change the owner of a file
clearstatcache — Clear File status cache
copy — Copy a file
delete — See unlink() or unset()
dirname — Return the directory part of the path
disk_free_space — Return the free space in the directory
disk_total_space — Return the total disk size of a directory
diskfreespace — Alias for disk_free_space()
fclose — Close an open file pointer
feof — Test whether the file pointer has reached the end of the file
fflush — Output buffered contents to a file
fgetc — Read characters from a file pointer
fgetcsv — From Read a line from a file pointer and parse CSV fields
fgets — Read a line from a file pointer
fgetss — Read a line from a file pointer and filter out HTML tags
file_exists — Check if a file or directory exists
file_get_contents — Get an entire file Read a string
file_put_contents — Write a string to a file
file — Read the entire file into an array
fileatime — Get the last access time of the file
filectime — Get the inode modification time of the file
filegroup — Get the file The group
fileinode — Get the inode of the file
filemtime — Get the file modification time
fileowner — Get the owner of the file
fileperms — Get the permissions of the file
filesize — Get the file size
filetype — Get the file type
flock — A lightweight advisory document Lock
fnmatch — Match a file name with a pattern
fopen — Open a file or URL
fpassthru — Output any remaining data at the file pointer
fputcsv — Format the row to CSV and write to the file pointer
fputs — Alias for fwrite()
fread — Read a file (safe for use with binary files)
fscanf — Format input from a file
fseek — Locate in a file pointer
fstat — Get file information via an open file pointer
ftell — Return a file pointer read/ Where to write
ftruncate — Truncate a file to a given length
fwrite — Write a file (safe for binary files)
glob — Find a file path that matches a pattern
is_dir — Determine if a given filename is a directory
is_executable — Determines whether the given file name is executable
is_file — Determines whether the given file name is a normal file
is_link — Determines whether the given file name is a symbolic link
is_readable — Determines whether the given file name is readable
is_uploaded_file — Determines whether the file was uploaded via HTTP POST
is_writable — Determines whether the given file name is writable
is_writeable — Alias of is_writable()
lchgrp — Changes group ownership of symlink
lchown — Changes user ownership of symlink
link — Establish a hard link
linkinfo — Get information about a connection
lstat — Give information about a file or symbolic link
mkdir — Create a new directory
move_uploaded_file — Move uploaded files to a new location
parse_ini_file — Parse a configuration file
pathinfo — Returns file path information
pclose — Closes the process file pointer
popen — Opens the process file pointer
readfile — Outputs a file
readlink — Returns the target pointed to by the symbolic link
realpath — Returns the normalized absolute path name
rename — Renames a file or directory
rewind — rewind the position of the file pointer
rmdir — delete the directory
set_file_buffer — alias for stream_set_write_buffer()
stat — give information about the file
symlink — create a symbolic link
tempnam — create a file with a unique file name
tmpfile — Create a temporary file
touch — Set the access and modification time of the file
umask — Change the current umask
unlink — Delete the file
mail — Send an email
(5) PHP commonly used mathematical functions and number processing functions
abs — absolute value
acos — inverse cosine
acosh — inverse hyperbolic cosine
asin — inverse sine
asinh — inverse hyperbolic sine
atan2 — arc tangent of two parameters
atan — arc tangent
atanh — inverse hyperbolic tangent
base_convert — Convert numbers between arbitrary bases
bindec — Binary to decimal conversion
ceil — Round to one
cos — Cosine
cosh — Hyperbolic cosine
decbin — Decimal to binary conversion
dechex — Decimal to decimal conversion Hexadecimal
decoct — Convert decimal to octal
deg2rad — Convert angle to radians
exp — Calculate the exponent of e
expm1 — Return exp(number) – 1, accurate results can be calculated even when the value of number is close to zero
floor — Rounding by rounding
fmod — Returns the floating point remainder of division
getrandmax — Displays the largest possible value of a random number
hexdec — Converts hexadecimal to decimal
hypot — Calculates the length of the hypotenuse of a right triangle
is_finite — Determine whether it is a finite value
is_infinite — Determine whether it is an infinite value
is_nan — Determine whether it is a legal value
lcg_value — Combined linear congruential generator
log10 — Logarithm with base 10
log1p — Return log(1 + number) , accurate results can be calculated even when the value of number is close to zero
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 better Random numbers
mt_srand — Sow the seeds for a better random number generator
octdec — Convert octal to decimal
pi — Get pi value
pow — Exponential expression
rad2deg — Convert radians to corresponding degrees
rand — Generate a random integer
round — Round a floating point number
sin — Sine
sinh — Hyperbolic sine
sqrt — Square root
srand — Seed a random number generator
tan — Tangent
tanh — Hyperbolic tangent
( 6) Functions commonly used in PHP database operations
mysql_affected_rows — Get the number of record rows affected by the previous MySQL operation
mysql_change_user — Change the user logged in in the active connection
mysql_client_encoding — Return the name of the character set
mysql_close — Close the MySQL connection
mysql_connect — Open a connection to the MySQL server
mysql_create_db — Create a new MySQL database
mysql_data_seek — Move the internal result pointer
mysql_db_name — Get the result data
mysql_db_query — Send a MySQL query
mysql_drop_db — Drop (delete) a MySQL database
mysq l_errno — Return to previous Numeric encoding of error messages in a MySQL operation
mysql_error — Returns the textual error message generated by the previous MySQL operation
mysql_escape_string — Escapes a string for use with mysql_query
mysql_fetch_array — Fetches a row from the result set as an associative array, or numeric array, Or both
mysql_fetch_assoc — Get a row from a result set as an associative array
mysql_fetch_field — Get column information from a result set and return it as an object
mysql_fetch_lengths — Get the length of each output in a result set
mysql_fetch_object — Get a row from a result set as an object
mysql_fetch_row — Get a row from the result set as an enumeration array
mysql_field_flags — Get the flags associated with the specified field from the result
mysql_field_len — Return the length of the specified field
mysql_field_name — Get the field name of the specified field in the result
mysql_field_seek — Focus the result The pointer is set to the specified field offset
mysql_field_table — Get the table name where the specified field is located
mysql_field_type — Get the type of the specified field in the result set
mysql_free_result — Release the result memory
mysql_get_client_info — Get MySQL client information
mysql_get_host_info — Get MySQL Host information
mysql_get_proto_info — Get MySQL protocol information
mysql_get_server_info — Get MySQL server information
mysql_info — Get the latest query information
mysql_insert_id — Get the ID generated by the previous INSERT operation
mysql_list_dbs — List all databases in the MySQL server
mys ql_list_fields — List the fields in the MySQL result
mysql_list_processes — List the MySQL processes
mysql_list_tables — List 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 connection to the MySQL server Persistent connections
mysql_ping — Ping a server connection, reconnect if not connected
mysql_query — Send a MySQL query
mysql_real_escape_string — Escape special characters in strings used in SQL statements, taking into account the connection’s current character set
mysql_result -Obtain results
Mysql_select_db — select mysql database
Mysql_Stat —Mysql_tableename ERY -Send a SQL query to mysql, and does not get and cache results
(7)php处理文件流常用函数
flush — 刷新输出缓冲
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 in 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正则处理常用函数
preg_grep — 返回与模式匹配的数组单元
preg_last_error — Returns the error code of the last PCRE regex execution
preg_match_all — 进行全局正则表达式匹配
preg_match — 进行正则表达式匹配
preg_quote — 转义正则表达式字符
preg_replace_callback — 用回调函数执行正则表达式的搜索和替换
preg_replace — 执行正则表达式的搜索和替换
preg_split — 用正则表达式分割字符串
ereg_replace — 正则表达式替换
ereg — 正则表达式匹配
eregi_replace — 不区分大小写的正则表达式替换
eregi — 不区分大小写的正则表达式匹配
split — 用正则表达式将字符串分割到数组中
spliti — 用正则表达式不区分大小写将字符串分割到数组中
sql_regcase — 产生用于不区分大小的匹配的正则表达式
(9)php session处理方面的常用函数
session_cache_expire — Return current cache expire
session_cache_limiter — Get and/or set the current cache limiter
session_commit — session_write_close() 的别名
session_decode — Decodes session data from a string
session_destroy — Destroys all data registered to a session
session_encode — 将当前会话数据编码为一个字符串
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 is 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
(10)php字符串处理常用的函数
addcslashes — Use backslashes to escape characters in a string in C style
addslashes — Use backslashes to quote strings
bin2hex — Convert binary data to hexadecimal representation
chop — Alias for rtrim()
chr — Returns the specified character
chunk_split — Splits the string into small chunks
count_chars — Returns information about the characters used in the string
crc32 — Calculates the crc32 polynomial of a string
crypt — One-way string encryption (hashing)
echo — Output one or more strings
explode — Use 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 two 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 two 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 into 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 an 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
(11) Some other common functions of PHP
base64_decode — Decode data encoded using MIME base64
base64_encode — Encode data using MIME base64
get_headers — Get all headers sent by the server in response to an HTTP request
get_meta_tags — Extract all meta tag content from a file Property, returns an array
http_build_query — Generates the request string after URL-encoding
parse_url — Parses the URL, returning its components
rawurldecode — Decodes the encoded URL string
rawurlencode — Encodes the URL according to RFC 1738
urldecode — Decode an encoded URL string
urlencode — Encode a URL string
debug_zval_dump — Dumps a string representation of an internal zend value to output
doubleval — Alias for floatval()
empty — Check if a variable is empty
floatval — Get the floating point value of the variable
get_defined_vars — Returns an array composed of all defined variables
get_resource_type — Returns the resource type
gettype — Gets the type of the variable
import_request_variables — Imports GET/POST/Cookie variables into the global scope
intval — Gets the integer value of a variable
is_array — Finds whether a variable is an array
is_binary — Finds whether a variable is a native binary string
is_bool — Finds whether a variable is a boolean binary string
is_callable — Detect whether the parameter is a legal callable structure
is_double — Alias of is_float()
is_float — Detect whether the variable is a floating point type
is_int — Detect whether the variable is an integer
is_integer — Alias of is_int()
is_long — Alias of is_int()
is_null — Detects whether the variable is NULL
is_numeric — Detects whether the variable is a number or a string of numbers
is_object — Detects whether the variable is an object
is_real — Alias of is_float()
is_resource — Detects whether the variable is Resource Types
is_scalar — Finds whether a variable is a scalar
is_string — Finds whether a variable is a string
is_unicode — Finds whether a variable is a unicode string
isset — Finds whether a variable is set
print_r — Prints human-readable information about a variable.
serialize — Generate a storable representation of a value
settype — Set the type of a variable
strval — Get the string value of a variable
unserialize — Create a PHP value from a stored representation
unset — Release the given variable
var_dump — Print information about a variable
var_export — Output or return a string representation of a variable