dongyan5815 2017-02-20 14:06
浏览 31
已采纳

使用嵌入式html输出错误的PHP代码

I am trying to implement html code in my php code. I use

<?php
echo <<< _END
//HTML HERE
_END;
?>

The problem is that _END;?> shows on the page as well.

I edited directives for my websites folder in /etc/httpd/conf.d/mywebsite.conf with this code and I access the php file with mydomain.com/test . No .php extension added. If I access mydomain.com/test.php than there is no _END;?> in my html output, which is correct.

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)\/?$ $1.php [NC]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)\/?$ $1.html [NC]

</IfModule>

Any idea why am I seeing _END;?> in my website?

It seems that hiding .html works as it should, but .php gets incorrectly interpreted.

  • 写回答

1条回答 默认 最新

  • drkbpwk609294 2017-02-20 14:19
    关注

    You have an extra white space before or after the _END. Here is a link that will explain it in more detail. heredoc

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题