shimano55 Posted April 14, 2006 Share Posted April 14, 2006 Hey everyone. I need to know how to use php to change the value of a variable in my configuration file and resave the file with the variable having its new value. For instance, I want to change:[code] $var1 = 1; [/code]to[code] $var1 = 0; [/code]and then save the file with the new value for $var1.Thanks,shimano55 Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/ Share on other sites More sharing options...
wildteen88 Posted April 14, 2006 Share Posted April 14, 2006 You will want to look at [a href=\"http://uk.php.net/manual/en/function.fopen.php\" target=\"_blank\"]fopen[/a] and [a href=\"http://uk.php.net/manual/en/function.fwrite.php\" target=\"_blank\"]fwrite[/a] for what you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27021 Share on other sites More sharing options...
lansing Posted April 14, 2006 Share Posted April 14, 2006 I don't know if I just missed something, but what formate is the configuration file? If it is .php then just use wordpad & just save it. Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27023 Share on other sites More sharing options...
Prismatic Posted April 14, 2006 Share Posted April 14, 2006 [!--quoteo(post=364847:date=Apr 14 2006, 12:27 PM:name=lansing)--][div class=\'quotetop\']QUOTE(lansing @ Apr 14 2006, 12:27 PM) [snapback]364847[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't know if I just missed something, but what formate is the configuration file? If it is .php then just use wordpad & just save it.[/quote]"[b]I need to know how to use php[/b] to change the value of a variable in my configuration file" Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27045 Share on other sites More sharing options...
sneskid Posted April 14, 2006 Share Posted April 14, 2006 wildteen88 has the right answerthe php configuration file is a .ini file, you'll have to write some code to safely change the variables without messing the file up... maybe such code already exists, search google for it.some hosts don't give you access to the ini file though.There are also some ini values you can temporarily change (more like ignore) while the script is running. I know that's not what you wan't to do.. but just letting you know it's possible.Edit:Opps... I think I missunderstood what you meant by "configuration file"... are you talking about the main php ini file... or a file you've made?Still tho.. wildteen88 has the right answer Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27051 Share on other sites More sharing options...
kenrbnsn Posted April 14, 2006 Share Posted April 14, 2006 You should look at the function [a href=\"http://www.php.net/parse_ini_file\" target=\"_blank\"]parse_ini_file[/a]() and see if that helps you.Ken Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27059 Share on other sites More sharing options...
wildteen88 Posted April 15, 2006 Share Posted April 15, 2006 Umm, I dont think [b]shimano55[/b] wants to edit his php.ini file but a configuration file, ie config.php, for his script to edit a the value of $var1 to 0. shimano55 [b]doesn't[/b] want to edit the php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/7420-changing-a-value-in-a-configphp/#findComment-27189 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.