dqe55175 2011-03-07 06:50
浏览 92
已采纳

php只能从文档根目录下工作吗?

I am using ubuntu 11.04 with an apache-mysql server (I think that is called LAMP) on a firefox web browser. If I put a php file in my document root, and then type http://localhost/myfile.php, it runs fine. But if I simply click it, it opens up firefox and prompts me to save or download the file. If I put it, say, on my desktop, and doubleclick it, it does the save or download thing. Why is this, and can I configure it so that I can just click and display like a normal html file would?

  • 写回答

2条回答 默认 最新

  • douzuan5365 2011-03-07 06:54
    关注

    A PHP file needs to be interpreted server-side before it reaches the browser. If you just open it using file:///foo/bar/myfile.php, Firefox won't know what to do with it, because Firefox doesn't interpret PHP. Conversely, how would Firefox know that /foo/bar/myfile.php should be opened using the completely unrelated address http://localhost/myfile.php?

    Bottom line: it just doesn't work that way.

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

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn