Php basic learning -- strstr () function PHPstrstr () function PHPString function definition and usage strstr () function searches for the first occurrence of a string in another string. This function returns the rest of the string (from the matching point ). If the searched string is not found, false is returned. Basic php learning-strstr () function
PHP strstr () function
PHP String function
Definition and usage
The strstr () function searches for the first occurrence of a string in another string.
This function returns the rest of the string (from the matching point ). If the searched string is not found, false is returned.
Syntax
strstr(string,search)
Parameter description
String |
Required. Specifies the string to be searched. |
Search |
Required. Specifies the string to be searched. If this parameter is a number, search for characters that match the ASCII value of the number. |
Tips and comments
Note: This function is binary secure.
Note: This function is case sensitive. For case-insensitive searches, use? Stristr ().
Example 1
strstr("Hello world!","world");?>
Output:
world!
Example 2
In this example, we will search for the characters represented by the ASCII value of "o:
strstr("Hello world!",111);?>
Output:
o world!
PHP String function