Need help editing/saving text files
I'm trying to be able to save to a text file
say if my text file contained:
define("NAMEOFAPP", "SOME APP");
define("DESCRIPT", "This is my description.");
define("SOMETEXT", "Blah Blah Blah");
I want to know how I can save over these. Not sure how to do this as I only know how to read, write, and append to text files.
You can, with ease. There are a number of functions available for preforming actions on files.
This site is where I gained my starters knowledge for PHP about 4 years ago. 2003 I believe. Anyways, it has the simple, down-to-earth knowledge you need.
For now, that's how I am going to conclude this post, but I will write a tutorial for you. Hopefully the PHP Guru's here can give me some feedback as well. Being it my first tutorial for PHP - ever.
Hopefully you'll understand the basic and expand the script on your own. If not, let me know.
Oh yeah, on a final note; you have to click continue to go through every basic function of the file.
I'm guessing you mean that you want to rewrite the file to have different values for each named constant?
if it was me i'd just truncate the exsiting file, then write to the file with the new constants
Thats why you can use;
First, on your FTP, you're going to make a map. Name it whatever your want. I am not sure, but CHMOD it to 777 (all) for sure. Same goes for webosb.txt.
Then open the file index.php and if it returns succes, you're good. Else, you gotta fix 1. the filename or 2. the content.
If it totally isn't writeable, CHMOD everything to 777.
I forgot to mention that the text file has a ton of other stuff in it... I guess my question is how do i locate the lines that contain those listed above and save over them in the same spot without affect any other text.
I guess i'm looking for a find and replace method.
What i was trying to do was create an editable config.php -- where I can load the values into the form which seems easy but I'm having trouble replacing those values. Is this practical?
Ok, here is a quick simple solution, im pretty sure there must be a better way to do this but anyways hope it helps you:
On one side theres test.txt (CHMOD this file to 777)
|All times are GMT. The time now is 01:42 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0