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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Thanks for the help. I was hoping there was an easy option somewhere that I was missing, but I guess not. I suppose the best thing to do is to just get the local database set up to mirror the sandbox database like PFMaBiSmAd suggested.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.