PHP5 common functions

巴扎黑
Release: 2023-03-02 18:44:01
Original
1142 people have browsed it

PHP has been updated to many versions, and the one that is used more recently is PHP5. Below we have summarized the common functions of PHP5 for you so that you can check them when actually writing code in the future.

pathinfo returns file path information, including the following array units: dirname, basename and extension.

func_num_args(), func_get_arg(), func_get_args()
glob— Find file paths matching the pattern
gzcompress() and gzuncompress() functions:
json_encode() and json_decode()
serialize() and unserialize() in My personal experience mainly deals with array transfer and array storage operations.

is_dir
mb_detect_encoding Automatically obtains the string encoding function
usleep() function delays code execution for several microseconds.
unpack() function unpacks data from a binary string. The
uniqid () function generates a unique ID based on the current time in microseconds.
time_sleep_until() function delays code execution until the specified time.
The time_nanosleep() function, a commonly used function in PHP5, delays code execution for a number of seconds and nanoseconds.
sleep() function delays code execution for a few seconds.
show_source() function performs syntax highlighting on files. The
strip_whitespace() function returns the source code file with PHP comments and whitespace characters removed. The
pack() function loads data into a binary string.
ignore_user_abort() function sets whether disconnecting from the client will terminate the execution of the script.
highlight_string() function performs syntax highlighting on strings.
highlight_file() function performs syntax highlighting on files.
The get_browser() function, a commonly used function in PHP5, returns the performance of the user's browser. The
eval() function evaluates strings according to PHP code.
defined() function checks whether a constant exists.
define() function defines a constant.
constant() function returns the value of a constant.
The connection_status() function, a commonly used function in PHP5, returns the current connection status.
connection_aborted() function checks whether the client is disconnected.
utf8_encode() function encodes ISO-8859-1 string to UTF-8.
utf8_decode() function decodes UTF-8 string to ISO-8859-1.
The wordwrap () function wraps the string according to the specified length.
nl2br
fgetcsv

vsprintf() function writes the formatted string into a variable.
vprintf() function outputs a formatted string.
vfprintf() function writes the formatted string to the specified output stream.
The ucwords () function, a commonly used function in PHP5, converts the first character of each word in the string to uppercase.
ucfirst() function converts the first character in a string to uppercase.
trim() function removes whitespace characters and other predefined characters from both ends of a string.
substr_replace() function replaces part of a string with another string.
substr_count() function counts the number of times a substring appears in a string.
substr_compare() function compares two strings from a specified starting length.
substr() function returns a part of a string.
strtr() function converts specific characters in a string.
The strtok() function, a commonly used function in PHP5, splits a string into smaller strings.
strstr() function searches for the first occurrence of a string within another string.
strspn() function returns the number of specific characters contained in a string.
strrpos() function finds the last occurrence of a string within another string.
strripos() function finds the last occurrence of a string within another string.
strrev() function reverses a string.
strrchr() function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string.
strpos() function returns the position of the first occurrence of a string in another string.
The strpbrk() function, a commonly used function in PHP5, searches for any one of the specified characters in a string.
strncmp() function compares two strings.
strncasecmp() function compares two strings.
strnatcmp() function uses a "natural" algorithm to compare two strings.
strnatcasecmp() function uses a "natural" algorithm to compare two strings.
strlen() function returns the length of the string.
stristr() function finds the first occurrence of a string within another string.
stripos() function returns the position of the first occurrence of a string in another string.
The stripslashes () function removes the backslashes added by the addslashes() function.
stripcslashes() function removes backslashes added by addcslashes() function.
strip_tags() function strips HTML, XML and PHP tags.
strcspn() function returns the number of characters searched in a string before any specified character is found.
The strcoll() function, a commonly used function in PHP5, compares two strings.
strcmp () function compares two strings.
strchr() function searches for the first occurrence of a string within another string.
strcasecmp() function compares two strings.
str_word_count() function counts the number of words in a string.
str_split() function splits a string into an array.
str_shuffle () function randomly shuffles all characters in a string.
str_rot13() function performs ROT13 encoding on a string.
str_replace() function uses a string to replace other characters in a string.
str_repeat() function repeats a string a specified number of times.
str_pad() function pads the string to the specified length.
str_ireplace() function uses a string to replace other characters in a string.
PHP5 commonly used function sscanf() function parses input from a string according to the specified format.
sprintf () function writes the formatted string into a variable.
soundex() function calculates the soundex key of a string.
similar_text() function counts the number of matching characters in two strings. The
sha1_file() function calculates the SHA-1 hash of a file. The
sha1() function computes the SHA-1 hash of a string.
setlocale() function sets regional information (regional information).
PHP5 commonly used functions rtrim() P rtrim() function

basename — Returns the file name part of the path

dirname — Returns the directory part of the path

array_filter — Filters the units in the array with a callback function
array_flip — Exchange Keys and values in the array

array_count_values determines the number of times a character appears in the string

array_uintersect — Calculate the intersection of arrays, use callback functions to compare data
array_unique — Remove duplicate values in the array array_flip(array_flip())

arsort — Sort the array in reverse order and maintain the index relationship

array_sum — Calculate the sum of all values in the array

array_search — Search the array for a given value, returning the corresponding key name if successful

in_array — Check the array Whether there is a certain value

array_push — push one or more units to the end of the array (push)

array_unshift() function inserts one or more elements at the beginning of the array

array_values returns all the values in the input array and Create a numerical index for it. ////Use the array_values function to reindex

count_chars Returns the information of the characters used in the string

array_keys Returns all the key names in the array

array_slice Takes a segment from the array

key() Returns the current unit in the array Key name .

get_class_methods — Returns an array consisting of the 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 defined classes
get_declared_interfaces — Returns An array containing all declared interfaces
get_object_vars — Returns an associative array composed 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 — If the object belongs to this class or class If it is the parent class of this object, return TRUE
is_subclass_of — If this object is a subclass of this class, return TRUE
method_exists — Check whether the method of the class exists
property_exists — Check whether the object or class has this property

parse_str (url, arr) is to convert a url? The following parameters into an array
parse_url (string url) is to parse a complete url into an array
http_build_query is to convert an array into a url? The following parameter string will be automatically Perform urlencode processing
call_user_func_array

ctype_alnum -- Check whether it only contains [A-Za-z0-9]
ctype_alpha -- Check whether it only contains [A-Za-z]
ctype_cntrl -- Check whether it only contains classes It is a character control character such as " "
ctype_digit -- When checking, it is a string containing only numeric characters (0-9). Negative numbers and decimals will not be detected.

filter_var($email, FILTER_VALIDATE_EMAIL)
ctype_graph --Check whether It is a string that only contains characters that can be printed (except spaces)
ctype_lower -- Checks whether all characters are English letters and all are lowercase
ctype_print -- Checks whether it only contains characters that can be printed The string
ctype_punct -- Check whether it only contains printable characters that are not numbers/characters/spaces
ctype_space -- Check whether it only contains characters and spaces such as " "
ctype_upper -- Check whether all The characters are all English letters, and they are all uppercase
ctype_xdigit -- Check whether it is a hexadecimal string, which can only include "0123456789abcdef"


Related labels:
xml
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!