假如你的网站垃圾评论很多,大部分垃圾评论是带链接的,因为要增加反向链接嘛,所以你可以使用下面的小技巧来杜绝这些带链接的垃圾评论
strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。
语法:strstr(string,search)
参数string,必需。规定被搜索的字符串。
参数search,必需。规定所搜索的字符串。如果该参数是数字,则搜索匹配数字 ASCII 值的字符。
该函数对大小写敏感。如需进行大小写不敏感的搜索,请使用 stristr()。
strstr()函数简单演示
复制代码 代码如下:
echo strstr("Hello NowaMagic!", "NowaMagic");
?>
程序运行结果:
NowaMagic!
再来一个简单例子
复制代码 代码如下:
$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
?>
程序运行结果:
@example.com
这个函数可以用的地方很多。假如你的网站垃圾评论很多,,大部分垃圾评论是带链接的,因为要增加反向链接嘛,所以你可以使用下面的小技巧来杜绝这些带链接的垃圾评论。
复制代码 代码如下:
$content = $_POST['content'];
$garbage = strstr($content, "if($garbage == false)
{
// 数据库插入代码
}
else
{
echo "<script>alert('你的评论不能带有链接'); history.go(-1);</script>";
}
?>
嗯,大概就这样。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools