Home > Backend Development > PHP Tutorial > One article summarizes the most comprehensive commonly used functions in PHP (collection)

One article summarizes the most comprehensive commonly used functions in PHP (collection)

藏色散人
Release: 2023-04-11 10:42:01
forward
6227 people have browsed it

This article brings you relevant knowledge about PHP. It mainly summarizes the commonly used functions of PHP, including Math function, string function, array function, multi-byte string function, time function, and directory. Functions and file system functions. If you are interested, let’s take a look at them below. Everyone is welcome to collect and learn!

One article summarizes the most comprehensive commonly used functions in PHP (collection)

Math function

abs — Absolute value

acos — Arccosine

acosh — inverse hyperbolic cosine

asin — inverse sine

asinh — inverse hyperbolic sine

atan2 — arc tangent of two parameters

atan — anyway tangent

atanh — inverse hyperbolic tangent

base_convert — convert numbers between arbitrary bases

bindec — convert binary to decimal

ceil — carry One-way rounding

cos — Cosine

cosh — Hyperbolic cosine

decbin — Convert decimal to binary

dechex — Convert decimal to hexadecimal System

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 method

fmod — Returns the floating point remainder of division

getrandmax — Display the largest possible value of a random number

hexdec — Convert hexadecimal to decimal

hypot — Calculate the length of the hypotenuse of a right triangle

intdiv — Division The result is rounded

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 — Base 10 logarithm

log1p — Returns log(1 number), allowing accurate results even when 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 — Seed a better random number generator

octdec — Convert octal to decimal

pi — Get the value of pi

pow — Exponential expression

rad2deg — Convert the number of radians to the corresponding number of degrees

rand — Generate a random integer

round — Round floating point numbers

sin — Sine

sinh — Hyperbolic sine

sqrt — Square root

srand — Sow random number occurrences Container

tan — tangent

tanh — hyperbolic tangent

String functions

addcslashes — Used in C language style Backslash escapes characters in a string

addslashes — Use backslashes to quote strings

bin2hex — Function converts a binary string containing data to a hexadecimal value

chop — Alias ​​for rtrim

chr — Returns the specified character

chunk_split — Splits the string into small chunks

convert_cyr_string — Converts the character into a Cyrillic Convert a character to another

convert_uudecode — Decode a uuencode-encoded string

convert_uuencode — Encode a string using uuencode

count_chars — Return information about the characters used in the string

crc32 — Computes the crc32 polynomial of a string

crypt — One-way string hashing

echo — Outputs one or more strings

explode — Use one string to split another string

fprintf — Write the formatted string to the stream

get_html_translation_table — Return the translation table after using htmlspecialchars and htmlentities

hebrev — Convert logical-Hebrew to visual-Hebrew

hebrevc — Convert logical-Hebrew Convert to visual-Hebrew, and convert newlines

hex2bin — Convert hexadecimal string to binary string

html_entity_decode — Convert HTML entities to their corresponding characters

htmlentities — Convert characters to HTML escaped characters

htmlspecialchars_decode — Convert special HTML entities back to normal characters

htmlspecialchars — Convert special characters to HTML entities

implode — Convert the values ​​of a one-dimensional array into a string

join — Alias ​​implode

lcfirst — Make the first character of a string lowercase

levenshtein — Calculate the edit distance between two strings

localeconv — Get numeric formatting information

ltrim — Remove whitespace characters (or other characters) at the beginning of a string

md5_file — Calculate the MD5 hash value of the specified file

md5 — Calculate the MD5 hash value of a string

metaphone — Calculate the metaphone key of a string

money_format — Format a number into a currency string

nl_langinfo — Query language and locale information

nl2br — Insert an HTML line break before all new lines in the string

number_format — With Format a number with thousands separator

ord — Convert the first byte of the string to a value between 0-255

parse_str — Parse the string into multiple variables

print — Output string

printf — Output formatted string

quoted_printable_decode — Convert quoted-printable string to 8-bit string

quoted_printable_encode — Convert an 8-bit string to a quoted-printable string

quotemeta — escape metacharacter set

rtrim — remove whitespace characters (or other characters) at the end of the string

setlocale — Set locale information

sha1_file — Calculate the sha1 hash value of the file

sha1 — Calculate the sha1 hash value of the string

similar_text — Calculate two characters String similarity

soundex — Calculate the soundex key of a string

sprintf — Return a formatted string

sscanf — Parse the input characters according to the specified format

str_getcsv — Parse a CSV string into an array

str_ireplace — A case-ignoring version of str_replace

str_pad — Use another string to pad a string to the specified length

str_repeat — Repeat a string

str_replace — Substring replacement

str_rot13 — Perform ROT13 transformation on a string

str_shuffle — Randomly shuffle a string

str_split — Convert a string to an array

str_word_count — Return the usage of words in a string

strcasecmp — Binary safe comparison of strings (case insensitive)

strchr — alias strstr

strcmp — Binary-safe string comparison

strcoll — Locale-based string comparison

strcspn — Get the start sub of a non-matching mask Length of a string

strip_tags — Strip HTML and PHP tags from a string

stripcslashes — Dequote a string escaped using addcslashes

stripos — Find a string Position of first occurrence (case-insensitive)

stripslashes — Backquotes a quoted string

stristr — Case-ignoring version of the strstr function

strlen — Gets a string Length

strnatcasecmp — Compare strings using the “natural ordering” algorithm (case-insensitive)

strnatcmp — Compare strings using the natural ordering algorithm

strncasecmp — Binary-safe comparison A number of characters at the beginning of a string (case insensitive)

strncmp — Binary safe comparison of a number of characters at the beginning of a string

strpbrk — Find any one of a set of characters in a string Characters

strpos — Find the first occurrence of a string

strrchr — Find the last occurrence of a specified character in a string

strrev — Reverse a string

strripos — Calculate the position of the last occurrence of the specified string in the target string (not case-sensitive)

strrpos — Calculate the position of the last occurrence of the specified string in the target string

strspn — Calculate the length of the first substring in a string in which all characters exist in the specified character set.

strstr — Find the first occurrence of a string

strtok — Mark split string

strtolower — Convert a string to lowercase

strtoupper — Convert a character Convert string to uppercase

strtr — Convert the specified character

substr_compare — Binary safe comparison of strings (compare specified length from offset position)

substr_count — Count occurrences of a string Times

substr_replace — Replace the substring of the string

substr — Return the substring of the string

trim — Remove the blank characters (or other characters) at the beginning and end of the string

ucfirst — Converts the first letter of a string to uppercase

ucwords — Converts the first letter of each word in a string to uppercase

vfprintf — Converts formatting characters String writing stream

vprintf — Output a formatted string

vsprintf — Return a formatted string

wordwrap — Break the string into a specified number of words

Array function

array_change_key_case — Change all key names in the array to all uppercase or lowercase

array_chunk — Split an array into multiples

array_column — Returns a specified column in an array

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 all values ​​in an array

array_diff_assoc — Computes the difference of an array with index checking

array_diff_key — Computes the difference of an array using key name comparison

array_diff_uassoc — Computes the difference of an array with a user-provided The callback function does index checking to calculate the difference set of the array

array_diff_ukey — Use the callback function to compare the key names to calculate the difference set of the array

array_diff — Calculate the difference set of the array

array_fill_keys — Fill an array with specified keys and values ​​

array_fill — Fill an array with given values ​​

array_filter — Use a callback function to filter cells in an array

array_flip — Swapping keys and values ​​in an array

array_intersect_assoc — Computes the intersection of arrays with index checking

array_intersect_key — Computes the intersection of arrays using key name comparison

array_intersect_uassoc — Computes with index checking Intersection of arrays, use callback function to compare indexes

array_intersect_ukey — Use callback function to compare key names to calculate intersection of arrays

array_intersect — Calculate intersection of arrays

array_key_exists — Check whether the specified key name or index exists in the array

array_key_first — Gets the first key of an array

array_key_last — Gets the last key of an array

array_keys — Returns some or all of the keys in an array

array_map — Applies a callback function to each element of an array

array_merge_recursive — Recursively merges one or more arrays

array_merge — Merge one or more arrays

array_multisort — Sort multiple arrays or multidimensional arrays

array_pad — Fill an array with a value of the specified length

array_pop — Pop the last element of an array (pop)

array_product — Calculate the product of all values ​​in an array

array_push — Push one or more elements to the end of an array (push)

array_rand — Randomly remove one or more elements from an array

array_reduce — Use a callback function to iteratively reduce an array to a single value

array_replace_recursive — Use the passed array Recursively replace elements of the first array

array_replace — Replace elements of the first array with the passed array

array_reverse — Return an array with the cells in reverse order

array_search — In Search the array for a given value, and if successful, return the first corresponding key name

array_shift — Move the unit at the beginning of the array out of the array

array_slice — Remove a segment from the array

array_splice — remove a part of an array and replace it with another value

array_sum — sum all values ​​in an array

array_udiff_assoc — calculate the difference of an array with index checking, compare with callback function Data

array_udiff_uassoc — Computes the difference of an array with index checking, using a callback function to compare the data and index

array_udiff — Computes the difference of an array using a callback function to compare the data

array_uintersect_assoc — Computes the intersection of arrays with an index check, using a callback function to compare the data

array_uintersect_uassoc — Computes the intersection of an array with an index check, using a separate callback function to compare the data and indexes

array_uintersect — Computes an array Intersection of , use callback function to compare data

array_unique — Remove duplicate values ​​in the array

array_unshift — Insert one or more cells at the beginning of the array

array_values ​​— Return the array All values ​​in

array_walk_recursive — Recursively apply a user function to each member of the array

array_walk — Use a user-defined function to perform callback processing on each element in the array

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 — Counts the number of cells in an array, or the number of attributes 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 one step forward

end — Points the array’s internal pointer to the last element

extract — Extracts a variable from the array Import into the current symbol table

in_array — Check whether a value exists in an array

key_exists — Alias ​​array_key_exists

key — Get the key name from an associative array

krsort — Sort the array in reverse order by key

ksort — Sort the array by key

list — Assign the values ​​in the array to a set of variables

natcasesort — Sort an array case-insensitively using the “natural sort” algorithm

natsort — Sort an array using the “natural sort” algorithm

next — Move the internal pointers in the array to Move forward one position

pos — Alias ​​of current

prev — Rewind the internal pointer of the array one position

range — Create an array based on the range, containing the specified elements

reset — Point the internal pointer of the array to the first element

rsort — Reverse sort the array

shuffle — Shuffle the array

sizeof — count Alias ​​

sort — Sort an array

uasort — Sort values ​​in an array using a user-defined comparison function and maintain index association

uksort — Use a user-defined comparison The comparison function sorts the key names in the array

usort — Use the user-defined comparison function to sort the values ​​in the array

Multi-byte string functions

mb_check_encoding — Check whether the string is valid in the specified encoding

mb_chr — Get a specific character

mb_convert_case — Convert the string to uppercase or lowercase

mb_convert_encoding — Convert character encoding

mb_convert_kana — Convert “kana” one from another (“zen-kaku”, “han-kaku” and more)

mb_convert_variables — Convert one or more Character encoding of a variable

mb_decode_mimeheader — Decode the string in the MIME header field

mb_decode_numericentity — Decode the HTML numeric string into characters

mb_detect_encoding — Detect the encoding of the character

mb_detect_order — Set/get the detection order of character encoding

mb_encode_mimeheader — Encode string for MIME header

mb_encode_numericentity — Encode character to HTML numeric string reference

mb_encoding_aliases — Get aliases of a known encoding type

mb_ereg_match — Regular expression match for multibyte string

mb_ereg_replace_callback — Perform a regular expression search and replace with multibyte support using a callback

mb_ereg_replace — Replace regular expression with multibyte support

mb_ereg_search_getpos — Returns start point for next regular expression match

mb_ereg_search_getregs — Retrieve the result from the last multibyte regular expression match

mb_ereg_search_init — Setup string and regular expression for a multibyte regular expression match

mb_ereg_search_pos — Returns position and length of a matched part of the multibyte regular expression for a predefined multibyte string

mb_ereg_search_regs — Returns the matched part of a multibyte regular expression

mb_ereg_search_setpos — Set start point of next regular expression match

mb_ereg_search — Multibyte regular expression match for predefined multibyte string

mb_ereg — Regular expression match with multibyte support

mb_eregi_replace — Replace regular expression with multibyte support ignoring case

mb_eregi — Regular expression match ignoring case with multibyte support

mb_get_info — 获取 mbstring 的内部设置

mb_http_input — 检测 HTTP 输入字符编码

mb_http_output — 设置/获取 HTTP 输出字符编码

mb_internal_encoding — 设置/获取内部字符编码

mb_language — 设置/获取当前的语言

mb_list_encodings — 返回所有支持编码的数组

mb_ord — Get code point of character

mb_output_handler — 在输出缓冲中转换字符编码的回调函数

mb_parse_str — 解析 GET/POST/COOKIE 数据并设置全局变量

mb_preferred_mime_name — 获取 MIME 字符串

mb_regex_encoding — Set/Get character encoding for multibyte regex

mb_regex_set_options — Set/Get the default options for mbregex functions

mb_scrub — Description

mb_send_mail — 发送编码过的邮件

mb_split — 使用正则表达式分割多字节字符串

mb_strcut — 获取字符的一部分

mb_strimwidth — 获取按指定宽度截断的字符串

mb_stripos — 大小写不敏感地查找字符串在另一个字符串中首次出现的位置

mb_stristr — 大小写不敏感地查找字符串在另一个字符串里的首次出现

mb_strlen — 获取字符串的长度

mb_strpos — 查找字符串在另一个字符串中首次出现的位置

mb_strrchr — 查找指定字符在另一个字符串中最后一次的出现

mb_strrichr — 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现

mb_strripos — 大小写不敏感地在字符串中查找一个字符串最后出现的位置

mb_strrpos — 查找字符串在一个字符串中最后出现的位置

mb_strstr — 查找字符串在另一个字符串里的首次出现

mb_strtolower — 使字符串小写

mb_strtoupper — 使字符串大写

mb_strwidth — 返回字符串的宽度

mb_substitute_character — 设置/获取替代字符

mb_substr_count — 统计字符串出现的次数

mb_substr — 获取部分字符串

时间函数

checkdate — 验证一个格里高里日期

date_add — 别名 DateTime::add

date_create_from_format — 别名 DateTime::createFromFormat

date_create_immutable_from_format — 别名 DateTimeImmutable::createFromFormat

date_create_immutable — 别名 DateTimeImmutable::__construct

date_create — 别名 DateTime::__construct

date_date_set — 别名 DateTime::setDate

date_default_timezone_get — 取得一个脚本中所有日期时间函数所使用的默认时区

date_default_timezone_set — 设定用于一个脚本中所有日期时间函数的默认时区

date_diff — 别名 DateTime::diff

date_format — 别名 DateTime::format

date_get_last_errors — 别名 DateTime::getLastErrors

date_interval_create_from_date_string — 别名 DateInterval::createFromDateString

date_interval_format — 别名 DateInterval::format

date_isodate_set — 别名 DateTime::setISODate

date_modify — 别名 DateTime::modify

date_offset_get — 别名 DateTime::getOffset

date_parse_from_format — Get info about given date formatted according to the specified format

date_parse — Returns associative array with detailed info about given date

date_sub — 别名 DateTime::sub

date_sun_info — Returns an array with information about sunset/sunrise and twilight begin/end

date_sunrise — 返回给定的日期与地点的日出时间

date_sunset — 返回给定的日期与地点的日落时间

date_time_set — 别名 DateTime::setTime

date_timestamp_get — alias DateTime::getTimestamp

date_timestamp_set — alias DateTime::setTimestamp

date_timezone_get — alias DateTime::getTimezone

date_timezone_set — alias DateTime::setTimezone

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 a UNIX timestamp of a GMT date

gmstrftime — Format a GMT/UTC time/date according to locale settings

idate — Convert local time Dates are formatted as integers

localtime — Get the local time

microtime — Return the current Unix timestamp and microseconds

mktime — Get the Unix timestamp of a date

strftime — Format local time/date according to locale

strptime — Parse date/time generated by strftime

strtotime — Parse any string datetime description into Unix timestamp

time — Returns the current Unix timestamp

timezone_abbreviations_list — alias DateTimeZone::listAbbreviations

timezone_identifiers_list — alias DateTimeZone::listIdentifiers

timezone_location_get — Alias ​​DateTimeZone::getLocation

timezone_name_from_abbr — Returns the timezone name from abbreviation

timezone_name_get — Alias ​​DateTimeZone::getName

timezone_offset_get — Alias ​​DateTimeZone::getOffset

timezone_open — alias DateTimeZone::__construct

timezone_transitions_get — alias DateTimeZone::getTransitions

timezone_version_get — Gets the version of the timezonedb

catalog function

chdir — Change directory

chroot — Change root directory

closedir — Close directory handle

dir — Return a Directory class instance

getcwd — Get the current working directory

opendir — Open a directory handle

readdir — Read entries from a directory handle

rewinddir — Rewind a directory handle

scandir — List files and directories in a specified path

File system functions

basename — Return the filename portion of a path

chgrp — Change The group the file belongs to

chmod — change the file mode

chown — change the owner of the file

clearstatcache — clear the file status cache

copy — copy the file

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 a Total disk size of the directory

diskfreespace — Alias ​​for disk_free_space

fclose — Close an open file pointer

feof — Test whether the file pointer reaches the end of the file

fflush — Output buffered contents to a file

fgetc — Read characters from a file pointer

fgetcsv — 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 — Read the entire file into a string

file_put_contents — Write a string into the 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 group of the file

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 file types

flock — Facility advisory file locking

fnmatch — Match filenames with patterns

fopen — Open files or URLs

fpassthru — Output all remaining data at the file pointer

fputcsv — Format lines 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 the file pointer

fstat — Get the file through the open file pointer INFO

ftell — Returns the position of the file pointer read/written from

ftruncate — Truncates the file to the given length

fwrite — Writes the file (safe for binary use file)

glob — Finds a file path that matches the pattern

is_dir — Determines whether the given file name is a directory

is_executable — Determines whether the given file name is executable

is_file — Determine whether the given file name is a normal file

is_link — Determine whether the given file name is a symbolic link

is_readable — Determine the given file name Whether it is readable

is_uploaded_file — Determines whether the file is uploaded through HTTP POST

is_writable — Determines whether the given file name is writable

is_writeable — Alias ​​of is_writable

lchgrp — Modify all groups of a symbolic link

lchown — Modify the owner of a symbolic link

link — Create 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 the uploaded file Go to new location

parse_ini_file — Parse a configuration file

parse_ini_string — Parse a configuration string

pathinfo — Return file path information

pclose — Close the process File pointer

popen — Open process file pointer

readfile — Output file

readlink — Return the target pointed to by the symbolic link

realpath_cache_get — Get the real directory cache Details

realpath_cache_size — Get the size of the real path buffer

realpath — Return the normalized absolute path name

rename — Rename 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

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of One article summarizes the most comprehensive commonly used functions in PHP (collection). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template