Skip to main content

Posts

Showing posts from April 25, 2011

configure ini like files in PHP

<? ///////////////////////////////////////////////////////////////////////// // // class.INIFile.php3 - implements a simple INIFile Parser // /// Author : Mo// // Description: // I just wandered how to sawe simple parameters not in a database but in a file // So starting every time from scratch isn't comfortable and I desided to write this // small unit for workin with ini like files // Some Examples: // // $ini = new INIFile("./ini.ini"); // //Read entire group in an associative array // $grp = $ini->read_group("MAIN"); // //prints the variables in the group // if ($grp) // for(reset($grp); $key=key($grp); next($grp)) // { // echo "GROUP ".$key."=".$grp[$key]."<br>"; // } // //set a variable to a value // $ini->set_var("NEW","USER","JOHN"); // //Save the file // $ini->save_data(); class INIFile { var $INI_FILE_NAME = ""; var $ERROR = ""…