
str_ireplace 함수는 특수문자를 제대로 처리하지 못하는 경우가 있습니다. 이럴 때는 PHP의 내장 함수인 addslashes()를 사용하여 특수문자를 처리할 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$str = "Hello, world!";
$str = str_ireplace('\', '', $str);
$str = addslashes($str);
echo $str;
또는 PHP 7.4 이상 버전에서는 preg_replace() 함수를 사용하여 특수문자를 처리할 수 있습니다.
#hostingforum.kr
php
$str = "Hello, world!";
$str = preg_replace('/\/', '', $str);
echo $str;
이러한 방법을 사용하여 특수문자를 처리할 수 있습니다.
2025-05-06 17:58