Jump to content
xisto Community
Sign in to follow this  
Arne-Christian

Writing To Files And Such

Recommended Posts

Ok lets say i have a config.php file, i want to edit something without open it, i know every line number and that, now how would i do this?

I will show you a example:

<?php$CONFIG['user']			=	'root';$CONFIG['server']		=	'localhost';$CONFIG['pass']			=	'******';$CONFIG['db']			=	'******';$CONFIG['install']		=	'1';$CONFIG['lang']			=	'en';?>

Now lets say i want to change $CONFIG['lang'], HOW would i do this without open the file?

Thanks :blink:

Share this post


Link to post
Share on other sites

Technically, the file is gonna be opened anyways, by the script, for reading and writing. :wacko: Though, i think it's best not to change permissions to the file.However, this is how i'd go about it. I'd use file_get_contents() to place everything in a variable. Then, use some kind of replacement function, to search for "$CONFIG['lang'] = 'en';", using some kind of regex, and replace whatever is the value. Then just overwrite the content of the file with the variable. But i don't know how good this will work. So, back up any files before testing. :blink:

Share this post


Link to post
Share on other sites

hi dear Arne-Christian Your are talking about value in php , its like smarty engine for template or change languche how we can use this ?for example we want make one script we n lan ! how ?How to include this File and value ?

Share this post


Link to post
Share on other sites

Uh, i am talking about variables and writing into files on specific places..., is it that hard to understand, When shall you get it into your head that i know more then the basics?Anyways i will try truefusions idea.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.