We help IT Professionals succeed at work.

saving php web pages

doctorbill asked
I am trying to save a php page to a local folder so that I can reopen it and have it connect to my database again. The original page is running on the  local website.
The reason I am doing this is so that the page can be reopened and edited and updated from the database.
How does one save a php page as a .php page with all the php code in place using the browser save as function, or a tab in the webpage ?
Watch Question

Most Valuable Expert 2011
Top Expert 2016
You cannot do this with the "save as" or a tab.  PHP is a server-side scripting language.  It never sends PHP code to the browser.
Most Valuable Expert 2011
Top Expert 2016
That said, here is what I do...

I have a text editor on my computer here, and I write my PHP scripts here.  Then I use an FTP client to upload the scripts to my server.  Then I visit them via a URL to see what the PHP script created.  It's a pretty good way of working -- I get to see the tests in exactly the same kind of HTTP - Server environment that my clients will see, and the save-then-upload process takes only a second or two.

HTH, ~Ray
Keith BrownAWS System Administrator
You have to get access to the file through FTP, SFTP, TFTP, etc. If it gets processed by your HTTP server, you'll never be able to get the original code, only the output.
Ray's suggestion has me thinking that perhaps it would help you to know different ways of developing.  Rays' method works and he's rather successful.

I'm a bit different.  I develop on my local computer with a PHP and MySQL server running.  When I think it's OK, I'll upload and test.

Either way, I think that it's a good idea to maintain the PHP code on your local computer and only send a copy to the server.

Or even better try and learn a little bit about various version control systems (VCS). They allow one or many users to access, modify and upload scripts to one central (depends on type of VCS) location.

It's really useful and I myself use this method because I develop in 3 different places and occasionally have people change my stuff as well.

Having a nice history of changes and quick way to revert to a version which worked before is another great feature of those.


most popular ones:

Most Valuable Expert 2011
Top Expert 2016
In version control, GIT is popular, too.


Good response

Explore More ContentExplore courses, solutions, and other research materials related to this topic.