即使沒有人可以複製你的問題,這裏有一個簡單的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
的字符串,這會將prop正確地解碼你的實體。
$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這個樣子
<腳本類型= 「文/ JavaScript的」> $(文件)。就緒(函數(){ \t $( 「#left_side_custom_image」)。點擊(函數(){ \t \t alert(「HELLO」); \t }); });
– Pritom