Home Backend Development PHP Tutorial PHP5 common functions

PHP5 common functions

Dec 01, 2016 am 11:51 AM
xml

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"


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can I open an XML file using PowerPoint? Can I open an XML file using PowerPoint? Feb 19, 2024 pm 09:06 PM

Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Using Python to merge and deduplicate XML data Using Python to merge and deduplicate XML data Aug 07, 2023 am 11:33 AM

Using Python to merge and deduplicate XML data XML (eXtensibleMarkupLanguage) is a markup language used to store and transmit data. When processing XML data, sometimes we need to merge multiple XML files into one, or remove duplicate data. This article will introduce how to use Python to implement XML data merging and deduplication, and give corresponding code examples. 1. XML data merging When we have multiple XML files, we need to merge them

Filtering and sorting XML data using Python Filtering and sorting XML data using Python Aug 07, 2023 pm 04:17 PM

Implementing filtering and sorting of XML data using Python Introduction: XML is a commonly used data exchange format that stores data in the form of tags and attributes. When processing XML data, we often need to filter and sort the data. Python provides many useful tools and libraries to process XML data. This article will introduce how to use Python to filter and sort XML data. Reading the XML file Before we begin, we need to read the XML file. Python has many XML processing libraries,

Convert XML data to CSV format in Python Convert XML data to CSV format in Python Aug 11, 2023 pm 07:41 PM

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

Import XML data into database using PHP Import XML data into database using PHP Aug 07, 2023 am 09:58 AM

Importing XML data into the database using PHP Introduction: During development, we often need to import external data into the database for further processing and analysis. As a commonly used data exchange format, XML is often used to store and transmit structured data. This article will introduce how to use PHP to import XML data into a database. Step 1: Parse the XML file First, we need to parse the XML file and extract the required data. PHP provides several ways to parse XML, the most commonly used of which is using Simple

Python implements conversion between XML and JSON Python implements conversion between XML and JSON Aug 07, 2023 pm 07:10 PM

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

Handling errors and exceptions in XML using Python Handling errors and exceptions in XML using Python Aug 08, 2023 pm 12:25 PM

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some

Python parsing special characters and escape sequences in XML Python parsing special characters and escape sequences in XML Aug 08, 2023 pm 12:46 PM

Python parses special characters and escape sequences in XML XML (eXtensibleMarkupLanguage) is a commonly used data exchange format used to transfer and store data between different systems. When processing XML files, you often encounter situations that contain special characters and escape sequences, which may cause parsing errors or misinterpretation of the data. Therefore, when parsing XML files using Python, we need to understand how to handle these special characters and escape sequences. 1. Special characters and

See all articles