Editing PHP Files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjohnson
Forum Newbie
Posts: 3
Joined: Wed Oct 01, 2008 12:30 pm

Editing PHP Files

Post by cjohnson »

In WordPress, you can edit the sites files from within the admin panel. I am building a site from scratch in php, and would like to build this into my site. Can anyone give me any suggestions on how to do this? How can you pull a list of files in a folder on my server, and then allow editing and savings of those files?

Thanks,
Chris
User avatar
aditya2071990
Forum Contributor
Posts: 106
Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:

Re: Editing PHP Files

Post by aditya2071990 »

That cannot be done with php alone, you need JavaScript too.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Editing PHP Files

Post by Eran »

You can fetch and display a list of files using glob() and iterate over the returned array. You can then open a selected file and load it into a textarea using one of the many file reading functions, such as file_get_contents(), and save it upon submission using one of the file saving functions such as file_put_contents().

Basically you would want to check out php file handling tutorials, such as this - http://www.codewalkers.com/c/a/Programm ... ext-files/.
User avatar
aditya2071990
Forum Contributor
Posts: 106
Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:

Re: Editing PHP Files

Post by aditya2071990 »

Thanks for the link mate
Post Reply