为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

How do I open PHP documents locally?

more options

I'm trying to mirror a website, and firefox won't open (local) PHP files, even though they're identical to html files, only with a different suffix. It keeps asking me whether I want to "Save As..." or "Open with". When I try to open them with Firefox, I get the same dialog box...

Is there a way to get Firefox to recognize that it can open PHP files? Or at least treat them as html files? I went through the General Preferences, and even tried to change the default program to Firefox (And even tried "automatically" -- what a mistake!!), and kept getting the same dialog box. checking the code in my text editor showed that it was a simple html document. I would rather not have to go through all my files and change the suffix of every document from "php" to "html". I would think there's a better way. Is there a viewer plugin? or would it just be a fix in General Preferences -> Applications? On my Mac, it would show the document "type" beside the content type, ie. html/text.

(Ubuntu 18.04, Firefox 66.0.2)

I'm trying to mirror a website, and firefox won't open (local) PHP files, even though they're identical to html files, only with a different suffix. It keeps asking me whether I want to "Save As..." or "Open with". When I try to open them with Firefox, I get the same dialog box... Is there a way to get Firefox to recognize that it can open PHP files? Or at least treat them as html files? I went through the General Preferences, and even tried to change the default program to Firefox (And even tried "automatically" -- what a mistake!!), and kept getting the same dialog box. checking the code in my text editor showed that it was a simple html document. I would rather not have to go through all my files and change the suffix of every document from "php" to "html". I would think there's a better way. Is there a viewer plugin? or would it just be a fix in General Preferences -> Applications? On my Mac, it would show the document "type" beside the content type, ie. html/text. (Ubuntu 18.04, Firefox 66.0.2)

所有回复 (2)

more options

A PHP file is a server-side file, so generally you don't run those files locally. Firefox won't be able to run any of the PHP portion of your code.

That said, you should have no issues rendering the HTML portion in Firefox. Do you get the same issue if open the file within Firefox (pressing Command + O on your Mac keyboard)?

more options

How difficult would it be for you to set up a local Apache server on your Linux system so you can "serve" the files to your browser(s) on the loopback address http://localhost or http://127.0.0.1 (possibly adding a port number)?

Considering the various different restrictions on file:// addresses compared with http:// addresses, I think that would be a closer simulation of the actual server, too.