jwinn Posted December 13, 2007 Share Posted December 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2007 Share Posted December 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 Wrap all your PHP in a HTML comment tag. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 Wrap all your PHP in a HTML comment tag. PHp processes Pre Hypertext that wouldn't work. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 Rename it to a .html file. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2007 Share Posted December 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 Thats why you wrap the PHP in a HTML comment. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2007 Share Posted December 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 what you need to do is include the file some how without reading its content in it of its self, but that causes an infinite loop so i'm outta ideas Quote Link to comment Share on other sites More sharing options...
jwinn Posted December 13, 2007 Author Share Posted December 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.