pri*_*ace 12 php modifier preg-replace
我一直收到这个错误:
警告:preg_match()[function.preg-match]:第235行的D:\ xampp\htdocs\administrator\components\com_smms\functions\plugin.php中的未知修饰符't'
上:
$PageContent = preg_replace($result->module_pregmatch, '', $PageContent);
Run Code Online (Sandbox Code Playgroud)
我在$ result-> module_pregmatch上做了一个var_dump,得到以下结果:
string '/<title>(.*)</title>/Ui' (length=23)
string '/<meta[^>]*name=["|\']description["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=77)
string '/<meta[^>]*name=["|\']keywords["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=74)
string '/<meta[^>]*name=["|\']author["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=72)
string '/<meta[^>]*name=["|\']copyright["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=75)
string '/<meta[^>]*name=["|\']robots["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=72)
string '/<meta[^>]*http=equiv=["|\']content-language["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=88)
string '/<meta[^>]*http-equiv=["|\']content-type["|\'][^>]*content=["|\'](.*)["|\']\s*\/>/Ui' (length=84)
string '/<link[^>]*href=["|\'](.*)["|\'][^>]*rel=["|\']shortcut[^>]*icon["|\'][^>]*type=["|\']image\/x-icon["|\']\s*\/>/Ui' (length=114)
string '/<link[^>]*href=["|\'](.*)["|\'][^>]*rel=["|\']alternate["|\'][^>]*type=["|\']application\/rss\+xml["|\'][^>]*title=["|\'](.*)["|\'][^>]\/>/Ui' (length=142)
string '/<link[^>]*href=["|\'](.*)["|\'][^>]*rel=["|\']alternate["|\'][^>]*type=["|\']application\/atom\+xml["|\'][^>]*title=["|\'](.*)["|\'][^>]\/>/Ui' (length=143)
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我我做错了什么吗?我一直坚持这个错误太久了...
Tom*_*igh 37
您使用正斜杠作为正则表达式模式分隔符,因此/<title>(.*)</title>/Ui'不起作用(</title>具有正斜杠).
例如,您应该能够转义正斜杠或使用不包含在模式中的其他分隔符
'/<title>(.*)<\/title>/Ui' //(esacaping)
Run Code Online (Sandbox Code Playgroud)
要么
'~<title>(.*)</title>~Ui' //different delimiter
Run Code Online (Sandbox Code Playgroud)