dongqing4070 2011-08-17 12:23
浏览 78
已采纳

Lighttpd在服务的html文件中转义<?php?>?

I'm working on a lighttpd server in an embedded system that is not configured by me. I use Google Chrome to see the source code for the HTML files. I don't know what's wrong but when I request the following simple file:

Note: the file extension is .html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Hello world!
<?php echo "PHP commands"?>
</body>
</html>

It gives the following file to my browser:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Hello world!
<!--?php echo "PHP commands"?-->
</body>
</html>

In other words it comments out the php commands disabling them! Why? How can I solve it? Couldn't find anything wrong in the config files.

Even though it is not saved in a file with .php extension, I want lighttpd to ignore the php commands inside the html. I know it's not a valid HTML, but I want it to be untouched.

  • 写回答

2条回答 默认 最新

  • dragon071111 2011-08-17 12:26
    关注

    My guess is that:

    1. The embedded system does not have a working PHP interpreter or is not configured for the file extension you are using.

    2. You are inspecting the HTML code through a browser tool (Firebug or something) that's not showing the original HTML but the generated HTML. Since <?php ... ?> is not a valid HTML tag, it's converted to a (valid) comment.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效