gpt4 book ai didi

php - 在 php 中显示 c++ 代码

转载 作者:太空宇宙 更新时间:2023-11-04 15:28:49 26 4
gpt4 key购买 nike

我试图在 php 中显示 .cpp 文件的内容。当我打印出来时,我正在使用 fread 加载它,它的格式不正确。如何在不转义每个字符的情况下保持格式?

最佳答案

假设您想在网络浏览器中查看它:

<pre>
<code>
<?php echo htmlspecialchars(file_get_contents($file)); ?>
</code>
</pre>

关于php - 在 php 中显示 c++ 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1107846/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com