Page 1 of 1

Viewing php files as html files

Posted: Wed Jul 21, 2010 10:00 pm
by agent57
I'm fairly new to php. I've got a Mac with OS X 10.6.4, Apache 2.2.14, and php 5.3.1. At the moment I'm working on a number of sites where I only edit the HTML in files where the php has already been set in place, or in includes where the code is all HTML but the file extension is .php.

Is there a way to set local .php files to be displayed as .html when opened in a browser? (And have the php parts just show up as text) At the moment, trying to open them in a browser brings up the "save as" dialogue.

I know I can change the extension, but it's time-consuming to do so. I've enabled php on my computer, and am able to view php files correctly through localhost, but due to the file structure of the sites I'm working on, it's difficult and sometimes impossible to navigate to the files I want to preview through localhost, and typing in addresses to the exact files is also kind of a pain. I would love to be able to just right click on a file, select open in Firefox, and get at least some idea of what the HTML content will look like.

Does anyone know of a way to do this? I've been searching around and have found things about parsing html files as php, but not the opposite. (I apologize if this has been answered or is mis-categorized. I searched for similar posts but couldn't find an answer.)


Re: Viewing php files as html files

Posted: Thu Jul 22, 2010 5:22 pm
by Bruno De Barros
PHP has to be processed by a PHP server. Yes, you could run a PHP script using the command line and see the resulting HTML, but that's pretty much useless if your script depends on browser data (sessions, cookies, even a simple URL). If you can't access websites made with PHP on a browser, you've got a big problem.

Re: Viewing php files as html files

Posted: Fri Jul 23, 2010 2:48 am
by josh
I can drag .php files into a firefox window and it shows up in the browser as text.