Newbie PHP Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Just starting to learn PHP and I am trying to build a simple web form.  I  
have a file that I use VI to open up and add information to.  I would like  
to create a web page that allows me to do two things with this file.  First,  
I need to search the file for a string of text. If what I am looking for is  
there, I do not need to do anything else.   If the text is not there, I need  
to edit the file,  add information to the bottom of the text and save it.  A  
bonus would be to make a dated backup copy of the file before saving.

I guess my main question is, will PHP allow me to do this and are there any  
links that I coud go to that would provide some insight in to how to do it.  
My PHP books do not go into detail on searching or editing text files.


Re: Newbie PHP Question

contained the following:

Quoted text here. Click to load it

Yes php can do all this.  I suggest you study the online manual for
strpos() for the search and file functions for the other operations.

For instance, file_get_contents() gets the contents of the file into a
string and strpos() allows you to search that haystack for a needle.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs

Re: Newbie PHP Question

In order to edit a file in PHP, you need fopen(), fwrite() and
fclose(). More details can be found in the manual [1].


Cheers, milahu

Site Timeline