PHP Common functions (1)

Source: Internet
Author: User
Tags binary to decimal mysql host mysql query natural logarithm unpack unique id value of pi xml parser
In the daily development, most novice is very puzzled, so many PHP built-in function how to remember, in fact, you just know that there is this thing is OK, use more time you naturally remember, the following collection of PHP development when the most commonly used functions, I hope to help you.

has recorded some common functions of PHP
The Usleep () function delays code execution for several microseconds.
The unpack () function unpack the data from a binary string.
The Uniqid () 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 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 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 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 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 specifies the function that is called when the parser finds a symbolic declaration in an 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.
The Xml_parser_create () function creates 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 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.
The WordWrap () function handles string wrapping at a specified length.
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 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 splits 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 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.
The Stripslashes () function deletes a backslash added by the addslashes () function.
The Stripcslashes () function deletes a 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 compares two strings.
The strcmp () function compares 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 parses input from a string according to the specified format.
The sprintf () 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
PHP String function
The Quotemeta () function adds a backslash before some of the predefined characters in the string.
The Quoted_printable_decode () function decodes a quoted-printable encoded string, returning a 8-bit string.
The printf () function outputs a formatted string.
The print () function outputs one or more strings.
The Parse_str () function parses the query string into a variable.
The Ord () function returns the ASCII value of the first character of a string.
The Number_format () function formats numbers by using thousands of groupings.
The NL2BR () function inserts an HTML line break (<br/>) before each new line (\ n) in the string.
The Nl_langinfo () function returns the specified local information.
The Money_format () function formats the string as a currency string.
The Metaphone () function computes the Metaphone key for the string.
The Md5_file () function computes the MD5 hash of the file.
The MD5 () function computes the MD5 hash of the string.
The LTrim () function removes spaces or other predefined characters from the left side of the string.
The Localeconv () function returns an array that contains the local numeric and currency information format.
The Levenshtein () function returns the Levenshtein distance between two strings.
The join () function combines array elements into a single string.
The implode () function combines array elements into a single string.
The Htmlspecialchars () function converts some pre-defined characters to HTML entities.
Html_entity_decode () Chars_decode () function

PHP String function
The Htmlentities () function converts a character to an HTML entity.
The Html_entity_decode () function converts an HTML entity to a character.
The HEBREVC () function converts a right-to-left stream of Hebrew text to a left-to-right stream. It also converts the new line (\ n) to <br/>.
The Hebrev () function converts a right-to-left stream of Hebrew text to a left-to-right stream.
The get_html_translation_table () function returns the translation tables used by the htmlentities () and Htmlspecialchars () functions.
The fprintf () function writes a formatted string to the specified output stream (for example, a file or database).
The explode () function splits the string into arrays.
The Echo () function outputs one or more strings.
The crypt () function returns a string that is encrypted with DES, Blowfish, or MD5.
The CRC32 () function computes the crc32 polynomial of a string.
The Count_chars () function returns information about the characters used in the string.
The Convert_uuencode () function encodes a string using the uuencode algorithm.
The Convert_uudecode () function decodes a uuencode encoded string.
The convert_cyr_string () function converts a character from one Cyrillic character to another.
The Chunk_split () function splits a string into a series of smaller parts.
The CHR () function returns characters from the specified ASCII value.
The chop () function removes whitespace characters or other predefined characters starting at the end of the string.
The Bin2Hex () function converts a string of ASCII characters to a hexadecimal value.
The Addslashes () function adds a backslash before the specified predefined character.
The Addcslashes () function adds a backslash before the specified character.
The XPath () function runs an XPath query to an XML document.
The simplexml_load_string () function loads an XML string into the object.
The simplexml_load_file () function loads an XML document into an object.
The Simplexml_import_dom () function converts a DOM node to a SimpleXMLElement object.
The Registerxpathnamespace () function creates a namespace context for the next XPath query.
The GetNamespace () function gets the namespaces that are used in the XML document.
The GetName () function Gets the name of the XML element from the SimpleXMLElement object.
The Getdocnamespaces () function returns the namespace declared in the XML document from the SimpleXMLElement object.
The children () function gets the child nodes of the specified node.
The attributes () function gets the properties of the SimpleXML element.
The Asxml () function returns an XML document from a SimpleXMLElement object in the form of a string.
The AddChild () function adds a child node to the specified XML node.
The AddAttribute () function adds an attribute to the SimpleXML element.
The __construct () function creates a new SimpleXMLElement object.
The Mysql_unbuffered_query () function sends a SQL query to MySQL (the results are not fetched/cached).
The mysql_thread_id () function returns the ID of the current thread.
The Mysql_stat () function returns the current system state of the MySQL server.
The mysql_select_db () function sets the active MySQL database.
The mysql_result () function returns the value of a field in the result set.
The mysql_real_escape_string () function escapes special characters in strings used in SQL statements.
The mysql_query () function executes a MySQL query.
The mysql_ping () function pings a server connection and re-connects if there is no connection.
The Mysql_pconnect () function opens a persistent connection to the MySQL server.
The mysql_num_rows () function returns the number of rows in the result set.
The Mysql_num_fields () function returns the number of fields in the result set.
The mysql_list_processes () function lists the MySQL process.
The Mysql_list_dbs () function lists all databases in the MySQL server.
The mysql_insert_id () function returns the ID generated by the previous insert operation.
The Mysql_info () function returns information for the most recent query.
The Mysql_get_server_info () function returns information about the MySQL server.
The Mysql_get_proto_info () function returns information about the MySQL protocol.
The Mysql_get_host_info () function returns information about the MySQL host.
The Mysql_get_client_info () function returns the MySQL client information.
The Mysql_free_result () function frees the resulting memory.
The Mysql_field_type () function returns the type of the specified field in the result set.
The mysql_field_table () function returns the name of the table that contains the specified field.
The Mysql_field_seek () function sets the pointer in the result set to the specified field offset.
The Mysql_field_name () function obtains the field name of the specified field in the result.
The Mysql_field_len () function returns the length of the specified field.
The Mysql_field_flags () function obtains the flags associated with the specified field from the result.
The Mysql_fetch_row () function takes a row from the result set as a numeric array.
The Mysql_fetch_object () function takes a row from the result set (Recordset) as an object.
The Mysql_fetch_lengths () function Gets the length of the contents of each field in a row.
The Mysql_fetch_field () function obtains column information from the result set and returns it as an object.
The MYSQL_FETCH_ASSOC () function obtains a row from the result set as an associative array.
The Mysql_fetch_array () function takes a row from the result set as an associative array, or as a numeric array, or both
The Mysql_error () function returns the text error message generated by the previous MySQL operation.
The Mysql_errno () function returns the numeric encoding of the error message in the previous MySQL operation.
The Mysql_db_name () function obtains the name of the database returned by the Mysql_list_dbs () call.
The Mysql_data_seek () function moves the pointer to the internal result.
The mysql_connect () function opens a non-persistent MySQL connection.
The Mysql_close () function closes a non-persistent MySQL connection.
The mysql_client_encoding () function returns the name of the currently connected character set.
The Mysql_affected_rows () function returns the number of record rows affected by the previous MySQL operation.
The Tanh () function returns the hyperbolic tangent.
The tan () function returns the tangent.
The Srand () function sows the random number generator seed.
The sqrt () function returns the square root of a number.
The Sinh () function returns the hyperbolic sine of a number.
The sin () function returns the sine of a number.
The round () function rounds a floating-point number.
The rand () function returns a random integer.
The Rad2deg () function converts the number of radians to the number of angles.
The POW () function returns the Y-side of X.
The PI () function returns the value of pi.
The Octdec () function converts octal into decimal.
Mt_srand () Seeding Mersenne Twister random number generator.
Mt_rand () returns a random integer using the Mersenne Twister algorithm.
Mt_getrandmax () Displays the maximum possible value for the random number.
MIN () returns the minimum value.
Max () returns the maximum value.
LOG1P () returns log (1 + x), and even when the value of x is close to 0, the exact result can be calculated.
LOG10 () The logarithm of the base 10.
Log () returns the natural logarithm.
Lcg_value () combined linear congruence generator.
Is_nan () Determines whether it is a valid value.
Is_infinite () Determines whether it is an infinite value.
The Is_finite () function determines whether it is a finite value.
The Hypot () function calculates the hypotenuse length of the triangle at all angles.
The Hexdec () function converts the 16 binary to decimal.
The Fmod () function displays the maximum possible value for the random number.
The Fmod () function returns the remainder of the floating-point number of divisions.
The floor () function rounds down to the nearest integer.
The EXPM1 () function returns exp (x)-1, even when the value of number is close to 0 to calculate the exact result.
The exp () function calculates the exponent of E.
The Deg2rad () function converts the angle to radians.
The DECOCT () function converts decimal into octal.
The Dechex () function converts decimal to 16 binary.
The Decbin () function converts decimal into binary.
The cosh () function returns the hyperbolic cosine of a number.
The Cos () function returns the cosine of a number.
The Ceil () function rounds up to the nearest integer.
The Bindec () function converts the binary into decimal.
The Base_convert () function converts numbers between arbitrary binaries.
The Atanh () function returns the inverse hyperbolic tangent of an angle.
Atan () and atan2 () and atan2 () functions

PHP Math function
Atan () and atan2 () and atan2 () functions

PHP Math function
The Asinh () function returns the inverse hyperbolic sine of a number.
The ASIN () function returns the inverse of a different value, and the result is a radian value between-PI/2 and PI/2.
The Acosh () function returns the inverse hyperbolic cosine of a number.
  • 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.