w3pop.com :: ÍøÂçѧԺ :: PHP :: PHP String
The string functions allow you to manipulate strings.
±¾ÀຯÊýÓÃÀ´¶Ô×Ö·û´®½øÐи÷ÖÖ²Ù×÷¡£
The string functions are part of the PHP core. There is no installation needed to use these functions.
±¾º¯Êý¿â×÷Ϊ PHP Äں˵ÄÒ»²¿·Ö£¬²»Óð²×°¾ÍÄÜʹÓá£
PHP: indicates the earliest version of PHP that supports the function.
PHP£º×îÔçÖ§³ÖÕâЩº¯ÊýµÄPHP°æ±¾
| Functionº¯Êý | Description˵Ã÷ | PHP |
|---|---|---|
| addcslashes() | Returns a string with backslashes in front of the specified characters Ïñ C ÄÇÑùʹÓ÷´Ð±ÏßתÒå×Ö·û´®ÖеÄ×Ö·û |
4 |
| addslashes() | Returns a string with backslashes in front of predefined characters ʹÓ÷´Ð±ÏßÒýÓÃ×Ö·û´® |
3 |
| bin2hex() | Converts a string of ASCII characters to hexadecimal values ½«¶þ½øÖÆÊý¾Ýת»»³ÉÊ®Áù½øÖƱíʾ |
3 |
| chop() | Alias of rtrim() rtrim() µÄ±ðÃûº¯Êý |
3 |
| chr() | Returns a character from a specified ASCII value ·µ»ØÖ¸¶¨µÄ×Ö·û |
3 |
| chunk_split() | Splits a string into a series of smaller parts ½«×Ö·û´®·Ö¸î³ÉС¿é |
3 |
| convert_cyr_string() | Converts a string from one Cyrillic character-set to another ½«×Ö·ûÓÉÒ»ÖÖ Cyrillic ×Ö·ûת»»³ÉÁíÒ»ÖÖ |
3 |
| convert_uudecode() | Decodes a uuencoded string ¶ÔÓÃuuencodeËã·¨±àÂëµÄ×Ö·û´®½âÂë |
5 |
| convert_uuencode() | Encodes a string using the uuencode algorithm ÓÃuuencodeËã·¨¶Ô×Ö·û´®±àÂë |
5 |
| count_chars() | Returns how many times an ASCII character occurs within a string and returns the information ·µ»Ø×Ö·û´®ËùÓÃ×Ö·ûµÄÐÅÏ¢ |
4 |
| crc32() | Calculates a 32-bit CRC for a string ¼ÆËãÒ»¸ö×Ö·û´®µÄ crc32 ¶àÏîʽ |
4 |
| crypt() | One-way string encryption (hashing) ²»¿ÉÄæ¼ÓÃÜ£¨É¢ÁУ© |
3 |
| echo() | Outputs strings Êä³ö×Ö·û´® |
3 |
| explode() | Breaks a string into an array ʹÓÃÒ»¸ö×Ö·û´®·Ö¸îÁíÒ»¸ö×Ö·û´® |
3 |
| fprintf() | Writes a formatted string to a specified output stream Êä³ö¸ñʽ»¯×Ö·û´®µ½Á÷ ½«¸ñʽ»¯ºóµÄ×Ö·û´®Ð´µ½Êä³öÁ÷ |
5 |
| get_html_translation_table() | Returns the translation table used by htmlspecialchars() and htmlentities() ·µ»Øhtmlspecialchars()ºÍhtmlentities()µÄת»»±í |
4 |
| hebrev() | Converts Hebrew text to visual text ת»»Ï£²®À´ÓïÎı¾Îª¿É¼ûÎı¾ |
3 |
| hebrevc() | Converts Hebrew text to visual text and new lines (n) into <br /> ת»»Ï£²®À´ÓïÎı¾Îª¿É¼ûÎı¾£¬»»ÐÐ (n) Ϊ <br /> |
3 |
| html_entity_decode() | Converts HTML entities to characters ת»»HTML×Ö·û±àÂëΪ×Ö·û |
4 |
| htmlentities() | Converts characters to HTML entities ת»»×Ö·ûΪHTML×Ö·û±àÂë |
3 |
| htmlspecialchars_decode() | Converts some predefined HTML entities to characters ת»»ÌØÊâHTML×Ö·û±àÂëΪ×Ö·û |
5 |
| htmlspecialchars() | Converts some predefined characters to HTML entities ת»»ÌØÊâ×Ö·ûΪHTML×Ö·û±àÂë |
3 |
| implode() | Returns a string from the elements of an array ½«Êý×éÔªËØ×éºÏΪ×Ö·û´®Êä³ö |
3 |
| join() | Alias of implode() ±ðÃû implode() |
3 |
| levenshtein() | Returns the Levenshtein distance between two strings ¼ÆËãÁ½¸ö×Ö·û´®µÄLevenshtein¾àÀë |
3 |
| localeconv() | Returns locale numeric and monetary formatting information ·µ»Øµ±µØµÄÊý×ֺͻõ±Ò¸ñʽÐÅÏ¢ |
4 |
| ltrim() | Strips whitespace from the left side of a string È¥³ý×Ö·û´®×ó¶ËµÄ¿Õ°×£¨»òÆäËü×Ö·û£© |
3 |
| md5() | Calculates the MD5 hash of a string ¼ÆËã×Ö·û´®µÄMD5 hash |
3 |
| md5_file() | Calculates the MD5 hash of a file ¼ÆËãÎļþµÄMD5 hash |
4 |
| metaphone() | Calculates the metaphone key of a string ¼ÆËã×Ö·û´®µÄmetaphone ¼ü |
4 |
| money_format() | Returns a string formatted as a currency string ½«Êý×Ö¸ñʽ»¯Îª»õ±ÒÐÎʽ |
4 |
| nl_langinfo() | Returns specific local information »ñÈ¡ÓïÑÔ¼°±¾µØÐÅÏ¢ |
4 |
| nl2br() | Inserts HTML line breaks in front of each newline in a string ÔÚ×Ö·û´®µÄÿ¸öÐÂÐÐǰ²åÈëHTML»»ÐбêÖ¾ |
3 |
| number_format() | Formats a number with grouped thousands ÓÃǧλ·Ö¸ô·ûºÅ¸ñʽ»¯Êý×Ö |
3 |
| ord() | Returns the ASCII value of the first character of a string ·µ»Ø×Ö·û´®ÖÐÊ××Ö·ûµÄASCIIÂëÖµ |
3 |
| parse_str() | Parses a query string into variables ½«×Ö´®·û½âÎöΪ±äÁ¿ |
3 |
| print() | Outputs a string Êä³ö×Ö·û´® |
3 |
| printf() | Outputs a formatted string Êä³ö¸ñʽ»¯×Ö·û´® |
3 |
| quoted_printable_decode() | Decodes a quoted-printable string ת»»quoted-printable×Ö·û´®Îª8λ×Ö·û´® |
3 |
| quotemeta() | Quotes meta characters תÒå×Ö·û´®ÖеÄmeta×Ö·û |
3 |
| rtrim() |
Strips whitespace from the right side of a string |
3 |
| setlocale() | Sets locale information ÉèÖñ¾»¯ÐÅÏ¢ |
3 |
| sha1() | Calculates the SHA-1 hash of a string ¼ÆËã×Ö·û´®µÄSHA-1 hash |
4 |
| sha1_file() | Calculates the SHA-1 hash of a file ¼ÆËãÎļþµÄSHA-1 hash |
4 |
| similar_text() | Calculates the similarity between two strings ¼ÆËãÁ½¸ö×Ö·û´®µÄÏàËÆÐÔ |
3 |
| soundex() | Calculates the soundex key of a string ¼ÆËã×Ö·û´®µÄsoundx key |
3 |
| sprintf() | Writes a formatted string to a variable Êä³ö¸ñʽ»¯×Ö·û´®µ½±äÁ¿ |
3 |
| sscanf() | Parses input from a string according to a format °´ÕÕÒ»¶¨¸ñʽ½âÎöÊäÈëµÄ×Ö·û´® |
4 |
| str_ireplace() | Replaces some characters in a string (case-insensitive) ´óСд²»Ãô¸ÐµÄstr_replace(). |
5 |
| str_pad() | Pads a string to a new length ÓÃÒ»¸ö×Ö·û´®Ìî³äÁíÒ»¸ö×Ö·û´®µ½Ö¸¶¨³¤¶È |
4 |
| str_repeat() | Repeats a string a specified number of times ÖØ¸´×Ö·û´® |
4 |
| str_replace() | Replaces some characters in a string (case-sensitive) ½«Ä³¸ö×Ó×Ö·û´®¶¼Ì滻ΪÁíÒ»¸ö×Ö·û´®£¨´óСдÃô¸Ð£© |
3 |
| str_rot13() | Performs the ROT13 encoding on a string ¶Ô×Ö·û´®×÷ROT13±àÂë |
4 |
| str_shuffle() | Randomly shuffles all characters in a string Ëæ»ú´òÂÒ×Ö·û´®ÖеÄ×Ö·û˳Ðò |
4 |
| str_split() | Splits a string into an array ת»»×Ö·û´®ÎªÊý×é |
5 |
| str_word_count() | Count the number of words in a string ¼ÆËã×Ö·û´®ÖеĴÊÊý |
4 |
| strcasecmp() | Compares two strings (case-insensitive) ±È½ÏÁ½¸ö×Ö·û´®£¨´óСд²»Ãô¸Ð£© |
3 |
| strchr() | Finds the first occurrence of a string inside another string (alias of strstr()) ±ðÃû strstr() |
3 |
| strcmp() | Compares two strings (case-sensitive) ±È½ÏÁ½¸ö×Ö·û´®£¨´óСдÃô¸Ð£© |
3 |
| strcoll() | Locale based string comparison »ùÓÚ±¾µØµÄ×Ö·û´®±È½Ï |
4 |
| strcspn() | Returns the number of characters found in a string before any part of some specified characters are found ·µ»Ø×Ö·û´®ÖÐÆðÊײ»·ûºÏmaskµÄ×Ó×Ö·û´®³¤¶È |
3 |
| strip_tags() | Strips HTML and PHP tags from a string ³ýÈ¥×Ö·û´®ÖеÄHTMLºÍPHP±êÇ© |
3 |
| stripcslashes() | Unquotes a string quoted with addcslashes() ½«ÓÃaddcslashes()´¦ÀíºóµÄ×Ö·û´®·µ»ØÔÑù |
4 |
| stripslashes() | Unquotes a string quoted with addslashes() ½«ÓÃaddslashes()´¦ÀíºóµÄ×Ö·û´®·µ»ØÔÑù |
3 |
| stripos() | Returns the position of the first occurrence of a string inside another string (case-insensitive) ²éÕÒÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÊ״γöÏÖµÄλÖ㨴óСд²»Ãô¸Ð£© |
5 |
| stristr() | Finds the first occurrence of a string inside another string (case-insensitive) ´óСд²»Ãô¸ÐµÄstrstr() |
3 |
| strlen() | Returns the length of a string ×Ö·û´®³¤¶È |
3 |
| strnatcasecmp() | Compares two strings using a "natural order" algorithm (case-insensitive) ÓÃnatural orderËã·¨±È½Ï×Ö·û´®£¨´óСд²»Ãô¸Ð£© |
4 |
| strnatcmp() | Compares two strings using a "natural order" algorithm (case-sensitive) ÓÃnatural orderËã·¨±È½Ï×Ö·û´®£¨´óСдÃô¸Ð£© |
4 |
| strncasecmp() | String comparison of the first n characters (case-insensitive) ±È½Ï×Ö·û´®µÄǰn¸ö×Ö·û£¨´óСд²»Ãô¸Ð£© |
4 |
| strncmp() | String comparison of the first n characters (case-sensitive) ±È½Ï×Ö·û´®µÄǰn¸ö×Ö·û£¨´óСдÃô¸Ð£© |
4 |
| strpbrk() | Searches a string for any of a set of characters ²éÕÒ×Ö·û´®ÖеÄһϵÁÐ×Ö·û |
5 |
| strpos() | Returns the position of the first occurrence of a string inside another string (case-sensitive) ²éÕÒÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÊ״γöÏÖµÄλÖ㨴óСдÃô¸Ð£© |
3 |
| strrchr() | Finds the last occurrence of a string inside another string ²éÕÒÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÄ©´Î³öÏÖµÄλÖà |
3 |
| strrev() | Reverses a string µ¹×ª×Ö·û´® |
3 |
| strripos() | Finds the position of the last occurrence of a string inside another string (case-insensitive) ²éÕÒÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÄ©´Î³öÏÖµÄλÖ㨴óСд²»Ãô¸Ð£© |
5 |
| strrpos() | Finds the position of the last occurrence of a string inside another string (case-sensitive) ²éÕÒÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÄ©´Î³öÏÖµÄλÖ㨴óСдÃô¸Ð£© |
3 |
| strspn() | Returns the number of characters found in a string that contains only characters from a specified charlist ·µ»Ø×Ö·û´®ÖÐÆðÊ×·ûºÏmaskµÄ×Ó×Ö·û´®³¤¶È |
3 |
| strstr() | Finds the first occurrence of a string inside another string (case-sensitive) ·µ»ØÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÊ״γöÏÖµÄλÖõ½ºóÕßĩβµÄ×Ó×Ö·û´®£¨´óСдÃô¸Ð£© |
3 |
| strtok() | Splits a string into smaller strings ½«×Ö·û´®·Ö¸î³ÉС¿é |
3 |
| strtolower() | Converts a string to lowercase letters תΪСд×Öĸ |
3 |
| strtoupper() | Converts a string to uppercase letters תΪ´óд×Öĸ |
3 |
| strtr() | Translates certain characters in a string ת»»×Ö´®ÖÐһЩ×Öĸ |
3 |
| substr() | Returns a part of a string ·µ»Ø×Ó×Ö´® |
3 |
| substr_compare() | Compares two strings from a specified start position (binary safe and optionally case-sensitive) ´ÓÒ»¶¨ÆðʼλÖÃÔÚÒ»¶¨³¤¶ÈÄڱȽÏÁ½¸ö×Ö´®·û£¨¶þ½øÖƾ«È·£¬´óСдÃô¸Ð¿ÉÑ¡£© |
5 |
| substr_count() | Counts the number of times a substring occurs in a string ²éÕÒ×Ó×Ö·û´®³öÏÖ´ÎÊý |
4 |
| substr_replace() | Replaces a part of a string with another string Ìæ»»×Ö·û´®ÖÐÒ»²¿·ÖΪÁíÒ»×Ö·û´® |
4 |
| trim() | Strips whitespace from both sides of a string È¥³ý×Ö·û´®Ê×ĩβµÄ¿Õ°×£¨»òÆäËü×Ö·û£© |
3 |
| ucfirst() | Converts the first character of a string to uppercase ×Ö·û´®Ê××Öĸ´óд |
3 |
| ucwords() | Converts the first character of each word in a string to uppercase ×Ö·û´®ÖÐÿ¸ö´ÊµÄÊ××Öĸ´óд |
3 |
| vfprintf() | Writes a formatted string to a specified output stream Êä³ö¸ñʽ»¯×Ö·û´®µ½Á÷ |
5 |
| vprintf() | Outputs a formatted string Êä³ö¸ñʽ»¯×Ö·û´® |
4 |
| vsprintf() | Writes a formatted string to a variable Êä³ö¸ñʽ»¯×Ö·û´®µ½±äÁ¿ |
4 |
| wordwrap() | Wraps a string to a given number of characters ½«×Ö·û´®°´×Ö·û¸öÊý»»ÐÐ |
4 |
PHP: indicates the earliest version of PHP that supports the constant.
PHP£º×îÔçÖ§³ÖÕâЩ³£Á¿µÄPHP°æ±¾
| Constant³£Á¿ | Description˵Ã÷ | PHP |
|---|---|---|
| CRYPT_SALT_LENGTH | Contains the length of the default encryption method for the system. For standard DES encryption, the length is 2 °üº¬ÏµÍ³Ê¹ÓõÄĬÈϼÓÃܱàÂ볤¶È¡£Ä¬Èϳ¤¶ÈΪ2 |
|
| CRYPT_STD_DES | Set to 1 if the standard DES-based encryption with a 2 character salt is supported, 0 otherwise Èç¹ûÖ§³Ö»ùÓÚDESµÄ2λ×Ö·û¼ÓÃܱàÂ룬ÄÇô¸Ã³£Á¿ÉèÖÃΪ1£»·ñÔòÉèÖÃΪ0 |
|
| CRYPT_EXT_DES | Set to 1 if the extended DES-based encryption with a 9 character salt is supported, 0 otherwise Èç¹ûÖ§³Ö»ùÓÚDESµÄ9λ×Ö·û¼ÓÃܱàÂ룬ÄÇô¸Ã³£Á¿ÉèÖÃΪ1£»·ñÔòÉèÖÃΪ0 |
|
| CRYPT_MD5 |
Set to 1 if the MD5 encryption with a 12 character salt starting with $1$ is supported, 0 otherwise |
|
| CRYPT_BLOWFISH | Set to 1 if the Blowfish encryption with a 16 character salt starting with $2$ or $2a$ is supported, 0 otherwise0 Èç¹ûÖ§³ÖBlowfishµÄ16λ×Ö·û¼ÓÃܱàÂ룬²¢ÇҸüÓÃܱàÂëÒÔ $2$ »ò$2a$Æðʼ£¬Ôò½«¸Ã³£Á¿ÉèÖÃΪ1£»·ñÔòÉèÖÃΪ0 |
|
| HTML_SPECIALCHARS | ||
| HTML_ENTITIES | ||
| ENT_COMPAT | ||
| ENT_QUOTES | ||
| ENT_NOQUOTES | ||
| CHAR_MAX | ||
| LC_CTYPE | ||
| LC_NUMERIC | ||
| LC_TIME | ||
| LC_COLLATE | ||
| LC_MONETARY | ||
| LC_ALL | ||
| LC_MESSAGES | ||
| STR_PAD_LEFT | ||
| STR_PAD_RIGHT | ||
| STR_PAD_BOTH |
ÆÀÂÛ (0)
All