Home > Backend Development > PHP Problem > What are the string methods in php

What are the string methods in php

青灯夜游
Release: 2023-03-08 09:02:01
Original
1883 people have browsed it

String methods include: ltrim() that removes blank characters or other characters on the left side of the string, count_chars() that returns the character information used in the string, echo() that outputs one or more strings, explode() that breaks up strings into arrays, hex2bin() that converts hexadecimal values ​​into ASCII characters, html_entity_decode() that converts HTML entities into characters, htmlentities() that converts characters into HTML entities, etc. .

What are the string methods in php

The operating environment of this tutorial: windows7 system, PHP8 version, DELL G3 computer

php string method (function)

The String function in PHP is a core component of PHP. No installation is required to use these functions.

  • addcslashes(): Returns a string with a backslash added before the specified character.

  • addslashes(): Returns a string with backslashes added before predefined characters.

  • bin2hex(): Convert a string of ASCII characters to a hexadecimal value.

  • chop(): Remove blank characters or other characters on the right side of the string.

  • chr(): Returns characters from the specified ASCII value.

  • chunk_split(): Split the string into a series of smaller parts.

  • convert_cyr_string(): Convert a string from one Cyrillic character set to another.

  • convert_uudecode(): Decode uuencode-encoded string.

  • convert_uuencode(): Use the uuencode algorithm to encode a string.

  • count_chars(): Returns information about the characters used in the string.

  • crc32(): Calculate the 32-bit CRC (cyclic redundancy check) of a string.

  • crypt(): One-way string encryption (hashing).

  • echo(): Output one or more strings.

  • explode(): Break up the string into an array.

  • fprintf(): Write the formatted string to the specified output stream.

  • get_html_translation_table(): Returns the translation table used by htmlspecialchars() and htmlentities().

  • hebrev(): Convert Hebrew text to visible text.

  • hebrevc(): Convert Hebrew text to visible text and convert new lines (\n) to
    .

  • hex2bin(): Convert a string of hexadecimal values ​​to ASCII characters.

  • html_entity_decode(): Convert HTML entities to characters.

  • htmlentities(): Convert characters into HTML entities.

  • htmlspecialchars_decode(): Convert some predefined HTML entities into characters.

  • htmlspecialchars(): Convert some predefined characters into HTML entities.

  • implode(): Returns a string composed of array elements.

  • join(): Alias ​​of implode().

  • lcfirst(): Convert the first character in the string to lowercase.

  • levenshtein(): Returns the Levenshtein distance between two strings.

  • localeconv(): Returns local number and currency format information.

  • ltrim(): Remove whitespace characters or other characters on the left side of the string.

  • md5(): Computes the MD5 hash of a string.

  • md5_file(): Calculate the MD5 hash of the file.

  • metaphone(): Calculates the metaphone key of a string.

  • money_format(): Returns a string formatted as a currency string.

  • nl_langinfo(): Returns the specified local information.

  • nl2br(): Inserts an HTML newline character before each new line in the string.

  • number_format(): Format numbers by thousands grouping.

  • ord(): Returns the ASCII value of the first character in the string.

  • parse_str(): Parse the query string into variables.

  • print(): Output one or more strings.

  • printf(): Outputs a 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(): Quote metacharacter.

  • rtrim(): Remove whitespace characters or other characters on the right side of the string.

  • setlocale(): Set regional information (regional information).

  • sha1(): Computes the SHA-1 hash of a string.

  • sha1_file(): Computes the SHA-1 hash of a file.

  • similar_text(): Calculate the similarity of two strings.

  • soundex(): Calculates the soundex key of a string.

  • sprintf(): Write the formatted string into a variable.

  • sscanf(): Parses input from a string according to the specified format.

  • str_getcsv(): Parse the CSV string into an array.

  • str_ireplace(): Replace some characters in the string (case insensitive).

  • str_pad(): Pad the string to the new length.

  • str_repeat(): Repeat the string a specified number of times.

  • str_replace(): Replace some characters in the string (case sensitive).

  • str_rot13(): Performs ROT13 encoding on a string.

  • str_shuffle(): Randomly shuffle all characters in the string.

  • str_split(): Split the string into an array.

  • str_word_count(): Count the number of words in a string.

  • strcasecmp(): Compares two strings (case insensitive).

  • strchr(): Find the first occurrence of a string in another string. (Alias ​​for strstr().)

  • strcmp(): Compares two strings (case sensitive).

  • strcoll(): Compares two strings (according to local settings).

  • strcspn(): Returns the number of characters searched in the string before any specified character is found.

  • strip_tags(): Strips HTML and PHP tags from a string.

  • stripcslashes(): Removes backslashes added by the addcslashes() function.

  • stripslashes(): Removes backslashes added by addslashes() function.

  • stripos(): Returns the position of the first occurrence of a string in another string (case insensitive).

  • stristr(): Find the first occurrence of a string in another string (case insensitive).

  • strlen(): Returns the length of the string. Chinese string processing uses the mb_strlen() function.

  • strnatcasecmp(): Uses a "natural ordering" algorithm to compare two strings (case insensitive).

  • strnatcmp(): Uses a "natural ordering" algorithm to compare two strings (case sensitive).

  • strncasecmp(): String comparison of the first n characters (case insensitive).

  • strncmp(): String comparison of the first n characters (case sensitive).

  • strpbrk(): Search for any one of the specified characters in the string.

  • strpos(): Returns the position of the first occurrence of a string in another string (case sensitive).

  • strrchr(): Find the last occurrence of a string in another string.

  • strrev(): Reverse a string.

  • strripos(): Find the last occurrence of a string in another string (case insensitive).

  • strrpos(): Find the last occurrence of a string in another string (case sensitive).

  • strspn(): Returns the number of specific characters contained in a string.

  • strstr(): Find the first occurrence of a string in another string (case sensitive).

  • strtok(): Split the string into smaller strings.

  • strtolower(): Convert the string to lowercase letters.

  • strtoupper(): Convert the string to uppercase letters.

  • strtr(): Convert specific characters in the string.

  • substr(): Returns a part of the string.

  • mb_substr(): Returns a part of the Chinese string.

  • substr_compare(): Compares two strings starting at a specified starting position (binary safe and optionally case-sensitive).

  • substr_count(): Count the number of times a substring appears in a string.

  • substr_replace(): Replace part of a string with another string.

  • trim(): Remove whitespace characters and other characters on both sides of the string.

  • ucfirst(): Convert the first character in the string to uppercase.

  • ucwords(): Convert the first character of each word in the string to uppercase.

  • vfprintf(): Write the formatted string to the specified output stream.

  • vprintf(): Outputs a formatted string.

  • vsprintf(): Write the formatted string into the variable.

  • wordwrap(): Wrap the string according to the specified length.

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of What are the string methods in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template