아무도 문제를 복제 할 수 있지만, 여기에 간단한 str_replace하여 해결하는 직접적인 방법이있다 : 같은
내 코드 보인다.
$input = '<p><script type="text/javascript"> $(document).ready(function() { $("#left_side_custom_image").click(function() { alert("HELLO"); }); }); </script></p> ';
$output = str_replace(array('{', '}'), array('{', '}'), $input);
Demo
편집 (오른쪽 상단에있는 '소스'링크를 클릭) : 지금 문제를 참조을. 당신의 입력 문자열 인 경우 :
는
"{hello}"
htmlentities
를 호출하면 출력이, 당신에게 문자열 &
는 나중에 &
로 다시 디코딩
"&#123;hello}"
을 제공하는 &
에 &
를 인코딩 :
"{hello}"
해결 방법은 html_entity_decode
을 통해 다시 문자열을 전송하는 것입니다. 귀하의 엔티티를 디코딩하십시오.
$custom_header = "{hello}";
$custom_header = htmlentities($custom_header);
$custom_header = html_entity_decode($custom_header);
echo html_entity_decode($custom_header); // Outputs {hello}
재생산 할 수 없습니다. http://codepad.org/EpUQzjrx이 동작을 보여주는 예제를 제공하십시오. – deceze
잘 작동합니다. –
내 $의 custom_header이
과 같이 <스크립트 유형 = "텍스트/자바 스크립트"> $ (문서) .ready (함수() { \t $ ("#의 left_side_custom_image"). 클릭 (함수() { \t \t 경고 ("HELLO"); \t }); });
– Pritom