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 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services