[英]php eregi deprecated code confusion on the syntax
我是php的新手,如何使用以下腳本從preg_match更改eregi:
if(!eregi("^select",$sql))
{
echo "wrongquery<br>$sql<p>";
echo "<H2>Wrong function silly!</H2>\n";
return false;
}
是否是這樣的:if(!eregi(“ / ^ select / i”,$ sql))
謝謝
用這個:
if (!preg_match ("/^select/i", $sql))
{
// do something...
}
不要將正則表達式用於字符串的簡單搜索,可以使用以下之一:
$query = "select * from";
$keyword = "select";
if(strpos($query, "select") === 0){
echo "found";
}
if(substr($query, 0, strlen("select")) === "select"){
echo "found";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.