$check = 'this is a string 111';
if ($check = 'this is a string') {
echo 'perfect match';
} else {
echo 'it did not match up';
}
Run Code Online (Sandbox Code Playgroud)
但它每次都返回完美的匹配,而不是它不匹配......我似乎无法得到字符串来匹配案例,它只会在字符串的一部分匹配时起作用.
如果我尝试使用电路板代码和正则表达式模式使事情变得复杂,那就变成了一场噩梦.
if ($check = '/\[quote(.*?)\](.*?)\[\/quote\]/su') {
$spam['spam'] = true;
$spam['error'] .= 'Spam post quote.<br />';
}
Run Code Online (Sandbox Code Playgroud)
因此,如果帖子只包含引号标签,它将被视为垃圾邮件并被抛弃,但我似乎无法解决它,也许我的模式是错误的.
Nic*_*ick 11
您需要使用==不只是=
$check = 'this is a string 111';
if ($check == 'this is a string') {
echo 'perfect match';
} else {
echo 'it did not match up';
}
Run Code Online (Sandbox Code Playgroud)
= 将分配变量.
== 会做一个宽松的比较
=== 会做一个严格的比较
请参阅比较运算符以获取更多信
您使用的是赋值运算符 ,=而不是等于运算符==。
你需要使用
if ($check == 'this is a string') {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34712 次 |
| 最近记录: |