如何在php函数strpos
中找到字符串中的元素。每当我用$ error字符串执行函数时,我都会得到一个解析错误。
[Symfony \ Component \ Debug \ Exception \ FatalErrorException]解析错误
$error = 'You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'"=<script>alert('o7v87r99ib')</script>"' at line 1';
$str = '=<script>alert('o7v87r99ib')</script>';
if(strpos($error, $str)){
echo 'Found: ' . $str;
}
答案 0 :(得分:1)
您有多个错误,您的$
字符串不是有效字符串。你的回音中也错过了来自str
的{{1}}。
<?php
$error = 'You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
\'"=<script>alert(\'o7v87r99ib\')</script>"\' at line 1';
$str = "=<script>alert('o7v87r99ib')</script>";
if(strpos($error, $str)){
echo 'Found: ' .$str;
}