$check = 'this is a string 111'; if ($check = 'this is a string') { echo 'perfect match'; } else { echo 'it did not match up'; }
但它每次都返回完美匹配,而不是它不匹配…我似乎无法得到字符串来匹配案例,它只会在字符串的一部分匹配时起作用.
如果我尝试使用电路板代码和正则表达式模式使事情变得复杂,那就变成了一场噩梦.
if ($check = '/\[quote(.*?)\](.*?)\[\/quote\]/su') { $spam['spam'] = true; $spam['error'] .= 'Spam post quote.<br />'; }
你需要使用==而不仅仅是=
$check = 'this is a string 111'; if ($check == 'this is a string') { echo 'perfect match'; } else { echo 'it did not match up'; }
=将分配变量.
==会做一个宽松的比较
===会做一个严格的比较
有关更多信息,请参见comparison operators.