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 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗