This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

ابحث في الدعم

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

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)

All Replies (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.