The Strstr () function searches for the first occurrence of a string in another string. The function returns the remainder of the string (from the matching point). returns false if the searched string is not found.
Syntax: Strstr (String,search)
Parameter string, required. Specifies the string to be searched.
Parameter search, required. Specifies the string to search for. If the parameter is a number, the character that matches the ASCII value of the number is searched.
The function is case-sensitive. For a case-insensitive search, use STRISTR ().
Strstr () function Simple Demo
Copy the Code code as follows:
Echo strstr ("Hello nowamagic!", "nowamagic");
?>
Program Run Result:
nowamagic!
One more simple example.
Copy the Code code as follows:
$email = ' name@example.com ';
$domain = Strstr ($email, ' @ ');
Echo $domain; Prints @example. com
$user = Strstr ($email, ' @ ', true); As of PHP 5.3.0
Echo $user; Prints name
?>
Program Run Result:
@example. com
This function can be used in a lot of places. If your site spam comments a lot, most of the spam comments are linked, because to add backlinks, so you can use the following tips to eliminate these linked spam comments.
Copy the Code code as follows:
$content = $_post[' content '];
$garbage = Strstr ($content, "if ($garbage = = False)
{
Database Insert Code
}
Else
{
echo "";
}
?>
Well, that's probably it.
http://www.bkjia.com/PHPjc/313556.html www.bkjia.com true http://www.bkjia.com/PHPjc/313556.html techarticle The strstr () function searches for the first occurrence of a string in another string. The function returns the remainder of the string (from the matching point). If the searched string is not found, then ...