使用strpos | PHP在字符串中查找脚本元素
如何使用php函数使用strpos | PHP在字符串中查找脚本元素,php,Php,如何使用php函数strpos在字符串中查找元素。每当我使用$error字符串执行函数时,我都会得到一个解析错误 [Symfony\Component\Debug\Exception\FatalErrorException]分析错误 $error='您的SQL语法有错误; 检查与MySQL服务器版本对应的手册 对于要使用的正确语法 “=第1行的警报('o7v87r99ib')”; $str='=警报('o7v87r99ib'); if(strpos($error,$str)){ echo“Fou
strpos
在字符串中查找元素。每当我使用$error字符串执行函数时,我都会得到一个解析错误
[Symfony\Component\Debug\Exception\FatalErrorException]分析错误
$error='您的SQL语法有错误;
检查与MySQL服务器版本对应的手册
对于要使用的正确语法
“=第1行的警报('o7v87r99ib')”;
$str='=警报('o7v87r99ib');
if(strpos($error,$str)){
echo“Found:”.$str;
}
您有多个错误,您的$error
字符串不是有效的字符串。您的echo中还缺少str
中的$
<?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;
}
突出显示的语法将显示您的错误并转义引号:$str='=alert(\'o7v87r99ib\')代码>完全正确。重写$str='=alert('o7v87r99ib');至$str=“=警报('o7v87r99ib')”@johncode我知道错误的原因,但我不知道解决方法。$error
字符串也是如此。把你的报价也整理一下。
<?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;
}