0
如何'請'htmlentities()
不要轉換某些符號?例如,如何不不使用htmlentities()來轉換某些符號?
PHP,
<?php echo htmlentities(file_get_contents('fonts.css'),ENT_QUOTES);?>
fonts.css,
@font-face {
font-family: 'ChunkFiveRoman';
src: url('chunkfive-webfont.eot'); /* EOT file for IE */
src: local('☺'), url('chunkfive-webfont.ttf') format('truetype'); /* TTF file for CSS3 browsers */
}
結果,
@font-face {
font-family: 'ChunkFiveRoman';
src: url('chunkfive-webfont.eot'); /* EOT file for IE */
src: local('�'), url('chunkfive-webfont.ttf') format('truetype'); /* TTF file for CSS3 browsers */
}
我想要保持 '☺',因爲它是,但不轉換它變成' º'。
可能嗎?
'htmlentities'不能像那樣工作,所以問題在其他地方。也許你的css文件是用utf-8編碼的,但是你用單字節編碼將它顯示爲HTML? – Jon 2012-01-18 17:23:55
謝謝喬恩。可能我以單字節編碼的形式將css顯示爲HTML ......但現在似乎馬里奧的答案可以正常工作。 – laukok 2012-01-18 17:32:53