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 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?