简体   繁体   English

本地 PHP 文件无法在 Firefox 中打开

[英]Local PHP file won't open in Firefox

When I right click my local PHP file and select "open with Firefox" Firefox gets the focus for a second, but then the file opens in Dreamweaver instead.当我右键单击我的本地 PHP 文件并选择“用 Firefox 打开”时,Firefox 会获得焦点一秒钟,但随后该文件在 Dreamweaver 中打开。 The same happens when I drag the file onto Firefox, or enter the URL ("file:///...") manually, or expressly select Firefox as the default application for PHP files.当我将文件拖到 Firefox 上,或手动输入 URL(“file:///...”),或明确选择 Firefox 作为 PHP 文件的默认应用程序时,也会发生同样的情况。 How can I get Firefox to show the file?如何让 Firefox 显示文件?

Firefox is not capable of handling PHP files, therefore it delegates their handling to a program that can do so (in your case, this is Dreamweaver). Firefox 无法处理 PHP 文件,因此它将处理委托给可以执行此操作的程序(在您的情况下,这是 Dreamweaver)。

PHP files should be served by a web server to the client (Firefox), which will display you the rendered content (probably HTML). PHP 文件应该由 Web 服务器提供给客户端 (Firefox),它会向您显示呈现的内容(可能是 HTML)。 PHP files are rendered by the PHP interpreter and then they are served using the HTTP protocol to a client as a web resource. PHP 文件由 PHP 解释器呈现,然后使用 HTTP 协议将它们作为 Web 资源提供给客户端。 So actually, you never open a PHP file with a browser, you just consume the HTTP resource that corresponds to the rendered output of that file.所以实际上,您永远不会使用浏览器打开 PHP 文件,您只是使用与该文件的呈现输出相对应的 HTTP 资源。

Firefox can show .html-files. Firefox 可以显示 .html 文件。 You have to install a webserver (xampp) to interprete .php-files.您必须安装一个网络服务器 (xampp) 来解释 .php 文件。 When xampp is installed, start xampp-control-panel, open your browser and (in case ur file is "test.php" in "c:\\xampp\\htdocs\\test.php") and type http://localhost/test.php .安装 xampp 后,启动 xampp-control-panel,打开浏览器(如果您的文件是“c:\\xampp\\htdocs\\test.php”中的“test.php”)并输入http://localhost/test.php

But first, right-click any php-file->Open with...->choose program, then select Firefox in the list.但首先,右键单击任何 php 文件->打开方式...->选择程序,然后在列表中选择 Firefox。

You must install a local web server like xamp, wamp or easyphp.您必须安装本地 Web 服务器,例如 xamp、wamp 或 easyphp。

Then you locate your files in that's www directory and see your file in browser with path:然后您在 www 目录中找到您的文件,并在浏览器中查看您的文件的路径:

localhost/myphp.php

Have a good time.玩的很开心。

I have this solution to open a php on linux :我有这个在 linux 上打开 php 的解决方案:

php -S localhost:8000 

and open a firefox and go to the page : http://localhost:8000/index.php It works well for me.并打开一个 Firefox 并转到该页面: http://localhost:8000/index.php 它对我来说效果很好。

The quickest way is to rename localhost/yourfile.php onto localhost/yourfile.html.最快的方法是将 localhost/yourfile.php 重命名为 localhost/yourfile.html。 (Tested on loop's Ubuntu 16.04 LTS) (在循环的 Ubuntu 16.04 LTS 上测试)

You should deactivate adblock for localhost (or your domain), it should runs.您应该为 localhost(或您的域)停用 adblock,它应该会运行。 ABP icon -> click on deactivate on localhost -> F5 ABP 图标 -> 在本地主机上点击停用 -> F5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM