PHP Developers Network
http://forums.devnetwork.net/

Viewing php files as html files
http://forums.devnetwork.net/viewtopic.php?f=39&t=118987
Page 1 of 1

Author:  agent57 [ Wed Jul 21, 2010 10:00 pm ]
Post subject:  Viewing php files as html files

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.)

Thanks!

Author:  Bruno De Barros [ Thu Jul 22, 2010 5:22 pm ]
Post subject:  Re: Viewing php files as html files

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.

Author:  josh [ Fri Jul 23, 2010 2:48 am ]
Post subject:  Re: Viewing php files as html files

I can drag .php files into a firefox window and it shows up in the browser as text.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/