PHP5 idiomatic functions

Source: Internet
Author: User
Tags rtrim unpack xml parser zip archive file
PHP5 Common functions

PHP has been updated to a number of versions, recently used more than the number of PHP5. Here we summarize the common functions of PHP5, so that you can actually write code in the future to see.

PathInfo returns information about the file path , including the following array cells:dirname,basename , and extension.

????? Func_num_args (), Func_get_arg (), Func_get_args ()

????? glob- Looking for file paths that match the pattern

????? Gzcompress () and Gzuncompress () functions:

????? Json_encode () and Json_decode ()
????? Serialize () and Unserialize ()

????? mb_detect_encoding? Get the string encoding function automatically

????? Iconv_strlen

????? Iconv_substr

The Usleep () function delays code execution for several microseconds.

The unpack () function unpack the data from a binary string.

uniqid The () function generates a unique ID based on the current time in microseconds.

The Time_sleep_until () function delays code execution until the specified time.

The Time_nanosleep () function of the PHP5 common function delays code execution for several seconds and nanoseconds.

  The sleep () function delays code execution for several seconds.

The Show_source () function highlights the file syntax.

The Strip_whitespace () function returns the source code file for the deleted PHP comments and whitespace characters.

The pack () function loads the data into a binary string.

  The ignore_user_abort () function sets the execution of the script to terminate if the client disconnects.

The highlight_string () function highlights the syntax of a string.

The Highlight_file () function highlights the file syntax.

The Get_browser () function of the PHP5 common function returns the performance of the user's browser.

The exit () function outputs a message and exits the current script.

The eval () function calculates the string according to the PHP code.

The die () function outputs a message and exits the current script.

The defined () function checks to see if a constant exists.

The Define () function defines a constant.

The constant () function returns the value of a constant.

The Connection_status () function of the PHP5 common function returns the current connection state.

The connection_aborted () function checks to see if the client is disconnected.

The Zip_read () function reads the next file in the Open zip archive.

The Zip_open () function opens a ZIP file for reading.

The Zip_entry_read () function obtains content from an open zip archive project.

The Zip_entry_open () function opens a ZIP archive entry for reading.

The Zip_entry_name () function of the PHP5 common function returns the name of the ZIP archive item.

The Zip_entry_filesize () function returns the original size of the ZIP archive item (before compression).

The Zip_entry_compressionmethod () function returns the compression method of the ZIP archive item.

The Zip_entry_compressedsize () function returns the compressed file size of a ZIP archive item.

The Zip_entry_close () function closes the zip archive file opened by the Zip_entry_open () function.

The Zip_close () function closes the zip archive file opened by the Zip_open () function.

The Xml_set_unparsed_entity_decl_handler () function specifies the function that is called when an unresolved entity name (NDATA) declaration is encountered.

The Xml_set_processing_instruction_handler () function specifies the function that is called when the parser finds processing instructions in an XML document.

The Xml_set_object () function allows an XML parser to be used in an object.

The Xml_set_notation_decl_handler () function of the PHP5 common function specifies the function that is called when the parser finds the symbolic declaration in the XML document.

The Xml_set_external_entity_ref_handler () function specifies the function that is called when the parser finds an external entity in the XML document.

The Xml_set_element_handler () function establishes the starting and terminating element processors.

The Xml_set_default_handler () function establishes the default data processor for the XML parser.

The Xml_set_character_data_handler () function establishes a character data processor.

The Xml_parser_set_option () function sets the option for the XML parser.

The Xml_parser_get_option () function obtains the option setting information from the XML parser.

The Xml_parser_free () function frees the XML parser.

PHP5 the Xml_parser_create () function of the common function to create an XML parser.

The Xml_parser_create_ns () function creates an XML parser with namespace support.

The Xml_parse_into_struct () function parses the XML data into an array.

The Xml_parse () function parses the XML document.

The Xml_get_error_code () function gets the XML parser error code.

The Xml_get_current_line_number () function gets the current line number of the XML parser.

The Xml_get_current_column_number () function Gets the current column number of the XML parser.

The Xml_get_current_byte_index () function of the PHP5 common function gets the current byte index of the XML parser.

The xml_error_string () function Gets the error description of the XML parser.

The Utf8_encode () function encodes the iso-8859-1 string as UTF-8.

The Utf8_decode () function decodes the UTF-8 string to iso-8859-1.

WordWrap () function to wrap a string with a specified length.

????? Nl2br

Fgetcsv

The vsprintf () function writes a formatted string to a variable.

The vprintf () function outputs a formatted string.

The vfprintf () function writes a formatted string to the specified output stream.

The ucwords() function of the PHP5 common function converts the first character of each word in a string to uppercase.

The Ucfirst () function converts the first character in a string to uppercase.

The trim () function removes white-space characters and other predefined characters from both ends of the string.

  The substr_replace () function replaces part of a string with another string.

The Substr_count () function calculates the number of occurrences of a substring in a string.

The Substr_compare () function compares two strings from a specified start length.

The substr () function returns a portion of a string.

The STRTR () function converts a specific character in a string.

The Strtoupper () function converts a string to uppercase.

The Strtolower () function converts a string to lowercase.

The Strtok () function of the PHP5 common function divides a string into smaller strings.

The Strstr () function searches for the first occurrence of a string in another string.

The STRSPN () function returns the number of specific characters contained in the string.

The Strrpos () function finds the position of the last occurrence of a string in another string.

The Strripos () function finds the position of the last occurrence of a string in another string.

The Strrev () function reverses the string.

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

The Strpos () function returns the position of the first occurrence of a string in another string.

The STRPBRK () function of the PHP5 common function searches the string for any one of the specified characters.

The strncmp () function compares two strings.

The strncasecmp () function compares two strings.

The strnatcmp () function uses a "natural" algorithm to compare two of strings.

The strnatcasecmp () function uses a "natural" algorithm to compare two of strings.

The strlen () function returns the length of the string.

The Stristr () function finds the position of the first occurrence of a string in another string.

The Stripos () function returns the position of the first occurrence of a string in another string.

stripslashes The () function removes the backslash added by the addslashes () function.

stripcslashes The () function removes the backslash added by the addcslashes () function.

The Strip_tags () function strips HTML, XML, and PHP tags.

The STRCSPN () function returns the number of characters to look up in a string before any of the specified characters are found.

The Strcoll () function of the PHP5 common function compares two strings.

strcmp () function to compare two strings.

The STRCHR () function searches for the first occurrence of a string in another string.

  The strcasecmp () function compares two strings.

The Str_word_count () function calculates the number of words in a string.

The Str_split () function splits a string into an array.

The Str_Shuffle() function randomly scrambles all characters in a string.

The str_rot13 () function performs ROT13 encoding on the string.

The Str_replace () function replaces some other characters in a string with a string.

The Str_repeat () function repeats a string for a specified number of times.

The Str_pad () function fills a string with the specified length.

The Str_ireplace () function replaces some other characters in a string with a string.

The sscanf () function of the PHP5 common function parses input from a string according to the specified format.

  sprintf The () function writes a formatted string to a variable.

The SOUNDEX () function computes the Soundex key for the string.

The Similar_text () function calculates the number of matching characters for two strings.

The Sha1_file () function computes the SHA-1 hash of the file.

The SHA1 () function computes the SHA-1 hash of the string.

The setlocale () function sets the region information (geographic information).

RTrim () P RTrim () function of PHP5 common functions

basename - Returns the file name portion of the path

dirname - Returns the directory portion of the path

?

array_filter-filter cells in an array with callback functions
Array_flip-exchanging keys and values in an array

Array_count_values determine the number of occurrences of a character in a string

Array_uintersect-computes the intersection of an array, compares the data with a callback function
array_unique -Removes duplicate values in the divisor group Array_flip (Array_flip ())

arsort-an array in reverse order and maintain an index relationship

Array_sum-computes the and of all values in the array

array_search-searches for the given value in the array, and returns the corresponding key name if successful

in_array-checks if a value exists in the array

Array_push -presses one or more cells into the end of the array (into the stack)

The 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 establishes a numeric index for them. //re-index using the Array_values function

Count_chars returns information about the characters used in the string

Array_keys Returns all the key names in the array

Array_slice remove a paragraph from an array

Key () returns the key name of the current cell in the array .

Get_class_methods-Returns an array consisting 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 -Checks whether the method of the class exists
property_exists-checking whether an object or class has this property

?

Parse_str is to convert a URL into an array after the argument
Array Parse_str (Url,arr)
Parse_url is to parse a full URL into an array
Array parse_url (string url)
Http_build_query is the conversion of an array into a URL, followed by a string of arguments that are automatically urlencode processed
String Http_build_query (Array formdata [, String Numeric_prefix])

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