1
preg_replace를 사용할 때 이스케이프해야하는 모든 문자의 목록을 찾을 수 있습니다. 내가 배열 $ ESCAPE_CHARS 배열에 그들 중 세 생각을 나열했습니다. 다른 것들은 내가 빠졌어.이스케이프 할 모든 PHP preg_replace 문자 목록
양식 제출시 preg replace를 수행 할 것이기 때문에이 항목이 필요합니다.
예.
$ESCAPE_CHARS = array("#", "^", "[");
foreach ($ESCAPE_CHARS as $char) {
$_POST{"string"} = str_replace("$char", "\\$char", $_POST{"string"});
}
$string = $_POST{"string"};
$test = "string of text";
$test = preg_replace("$string", "<b>$string</b>", $test);
고마워요!
을 우리가 왜 그 [**'preg_quote()'**] (http://php.net/preg-quote) – HamZa
에 http : // WWW. cheatography.com/davechild/cheat-sheets/regular-expressions/ –
'$ _POST { 'string'}'? '$ _POST [ 'string']'의 문제점은 무엇입니까? –