PHP strstr 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). Returns false if the searched string is not found.
Syntax
strstr(string,search)
Parameters | Description |
---|---|
string | Required. Specifies the string to be searched for. |
search | Required. Specifies the string to search for. If the argument is a number, then searches for characters matching the numeric ASCII value. |
Tips and Notes
Note: This function is binary safe.
Note: This function is case-sensitive. For case-insensitive searches, use stristr().
Example
Example 1
world!
Example 2
In this example, we will search for the character represented by the ASCII value of "o":
Output:
o world!
PHP uses the strstr() function to prevent spam comments
If your website has a lot of spam comments, most of the spam comments have links. , because you want to increase backlinks, so you can use the following tips to eliminate these spam comments with links.