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.

图片转代码服务由CSDN问答提供 功能建议

我正在使用未由我配置的嵌入式系统中的lighttpd服务器。 我使用谷歌浏览器查看HTML文件的源代码。 我不知道什么是错的,但是当我请求以下简单文件时:

注意:文件扩展名 是.html

 &lt;!DOCTYPE html PUBLIC“ -  // W3C // DTD XHTML 1.0 Transitional // EN”“http://www.w3  .org / TR / xhtml1 / DTD / xhtml1-transitional.dtd“&gt; 
&lt; html xmlns =”http://www.w3.org/1999/xhtml“&gt; 
&lt; head&gt; 
&lt; meta http  -equiv =“Content-Type”content =“text / html; charset = utf-8”/&gt; 
&lt; title&gt; Untitled Document&lt; / title&gt; 
&lt; / head&gt; 
 
&lt; body&gt; 
Hello  world!
&lt;?php echo“PHP命令”?&gt; 
&lt; / body&gt; 
&lt; / html&gt; 
   
 
 

它提供以下文件: 我的浏览器:

 &lt;!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”&gt; 
&lt; head&gt; 
&lt; meta http-equiv =“  Content-Type“content =”text / html; charset = utf-8“/&gt; 
&lt; ti  tle&gt; Untitled Document&lt; / title&gt; 
&lt; / head&gt; 
 
&lt; body&gt; 
Hello world!
&lt;! - ?php echo“PHP命令”? - &gt; 
&lt; / body&gt; \  n&lt; / html&gt; 
   
 
 

换句话说,它会注释掉禁用它们的php命令! 为什么? 我该如何解决? 在配置文件中找不到任何错误。

即使它没有保存在扩展名为.php的文件中,我也希望lighttpd忽略html中的php命令 。 我知道这不是一个有效的HTML,但我希望它不受影响。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

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条)

相关推荐 更多相似问题