Jump to content

How do you view pages locally, ignoring all PHP code?


jwinn

Recommended Posts

Is there anyway to view pages on my machine locally such that anything within the php tags is ignored? If I am running WAMP with error reporting off, I can't view the page because it's trying to access the database etc and just gives me a blank page. If I just open the file normally locally of course the php statements are printed as text and mess up the layout. I want to work on the layout and css locally without having to take out the php every time..this becomes an issue when you're working with multiple people making different edits, and I'd rather just be editing the same file.

Either make the local development environment functionally the same as the production environment (install a database server) so that the code functions (by the way it sounds like your code needs some error checking and error recovery logic to deal with things like a database server that could go down on your live site) or add a "testing" variable that you can test in your code to skip over any php code that you don't want to execute locally. You could also test the $_SERVER['REMOTE_ADDR'] to see if it starts with addresses that match your local network and skip over code if you request a page from your local network.

He already mentioned the problem doing something that has the same effect as that causes -

 

If I just open the file normally locally of course the php statements are printed as text and mess up the layout.

Then you are back to what cooldude832 said, all of the PHP output (or PHP source code if the file is .html) would appear inside a HTML comment all of the time and it would never be rendered by the browser.

 

Give it a try if you don't believe.

 

The OP does not want to have to search through the code and add/remove things like the php code or HTML comments around it every time he switches from local development to the live server.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.