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

报告相同问题?

悬赏问题

  • ¥15 Linux环境下CA证书更新问题
  • ¥15 sqlserver语句提取结果以外数据
  • ¥60 微信小程序如何上传QQ聊天文件
  • ¥300 开发的系统遭到无良商家的破解,请问如何防止再次发生,并追回损失
  • ¥15 java代码写在记事本上后在cmd上运行时无报错但又没生成文件
  • ¥15 关于#python#的问题:在跑ldsc数据整理的时候一直抱这种错误,要么--out识别不了参数,要么--merge-alleles识别不了参数(操作系统-linux)
  • ¥15 PPOCRLabel
  • ¥15 混合键合键合机对准标识
  • ¥100 现在不懂的是如何将当前的相机中的照片,作为纹理贴图,映射到扫描出的模型上
  • ¥15 安卓OpenCV人脸识别分类器加载