2009-06-22 19 views
12

Wciąż otrzymuję ten błąd:Dlaczego preg_replace zgłasza mi błąd "Nieznany modyfikator"?

Warning: preg_match() [function.preg-match]: Unknown modifier 't' in D:\xampp\htdocs\administrator\components\com_smms\functions\plugin.php on line 235

na:

$PageContent = preg_replace($result->module_pregmatch, '', $PageContent); 

robię var_dump na $ result-> module_pregmatch i pojawia się następujący:

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) 

Może ktoś proszę powiedz mi, co robię źle? Utknąłem na tym błędzie zbyt długo ...

Odpowiedz

37

Używasz przednich ukośników jako ogranicznika wzoru regex, więc /<title>(.*)</title>/Ui' nie zadziała (</title> ma ukośnik w przód).

Powinieneś być w stanie uciec ukośnik lub użyć innego ogranicznika, który nie jest zawarty w strukturze, na przykład

'/<title>(.*)<\/title>/Ui' //(esacaping) 

lub

'~<title>(.*)</title>~Ui' //different delimiter 
Powiązane problemy