doudou_3636 2017-11-16 10:27
浏览 208
已采纳

php file_get_contents()转换html实体,如ö 到ö

I try to display the contents of a php file in a textarea with

<textarea ...>
<?php echo file_get_contents("file.php"); ?>
</textarea>

but it converts the html entities like &ouml; to ö. As it is php code I can not use a conversion like htmlspecialchars because it would brick the <> and quotes etc.

EDIT:

I checked the sourcecode with the browser and there is really an ö.

Please help, thank you!

  • 写回答

3条回答 默认 最新

  • douju2331 2017-11-16 10:54
    关注

    htmlspecialchars will change:

    < &ouml;
    

    to:

    &lt; &amp;ouml;
    

    and it's ok.

    It will display in textarea:

    < &ouml;
    

    After you submit form, it will send to server text

    < &ouml;
    

    not:

    &lt; &amp;ouml;
    

    Tested in Chrome with jQuery:

    $('#layout').html('<form method="POST"><textarea name="x">&lt;&amp;ouml;</textarea><input type="submit" /></form>')
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度