我如何找到如果字符串包含"script"标记preg_match,…?我试图避免/上船提交,如果数据传递为"脚本"
$short_status = $this->params['form']['value'];
$regex = '/^[<script>]$/i';
if(preg_match($regex, $short_status))
{
die();
}
else
{
to process post and save to database,...
提前感谢,克里斯。
使用以下正则表达式:#</?script[^>]*>#i
.
if(preg_match('#</?script[^>]*>#i', '<script type="text/javascript">')){
echo 'SCRIPT FOUND';
}else{
echo 'Baah, nothing';
}
毕竟……以下是对我有用的:
$short_status = $this->params['form']['value'];
$regex = '/^<'w+|script|java|javascript|>$/';
if(preg_match($regex, $short_status))
{
die(); // aboard submission
}
else
{
// go to submission and save
享受它,……