PHP Classes

PHP INI Read and Write Class: Read and write configuration values in INI files

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (2 months ago) RSS 2.0 feedStarStarStar 53%Total: 1,320 This week: 2All time: 2,925 This week: 96Up
Version License PHP version Categories
php-ini-class 1.9GNU General Publi...4.0.4PHP 5, Files and Folders, Configuration
Description 

Author

This class can read and write configuration values in INI files.

It can parse a given INI file and extract the contained configuration values into class array variables.

The class can also do the opposite, i.e., write the configuration values in the array variable back to a INI file.

Picture of Radovan Janjic
  Performance   Level  
Name: Radovan Janjic is available for providing paid consulting. Contact Radovan Janjic .
Classes: 14 packages by
Country: Serbia Serbia
Age: 35
All time rank: 2382 in Serbia Serbia
Week rank: 34 Up1 in Serbia Serbia Up
Innovation award
Innovation award
Nominee: 3x

Details

PHP_INI_Read_Write

This class can read and write configuration values in INI files.

It can parse a given INI file and extract the contained configuration values into class array variables.

The class can also do the opposite, i.e., write the configuration values in the array variable back to a INI file.

Examples:

// Parse config.ini
$ini = new INI('config.ini');

// Content of: config.ini
print_r($ini->data);

// Udate settings
$ini->data['first_section']['animal'] = 'COW';

// Save settings to file
$ini->write();

// Update settings
$ini->data['first_section']['animal'] = 'HORSE';

// Add new setting to section third_section
$ini->data['third_section']['phpversion'][] = 5.4;

// Add new section third_section and new item something
$ini->data['fourth_section']['something'] = 'some data';

// Save settings to new file
$ini->write('config-2.ini');

// INI obj is now using ini 2 file
// Content of: config-2.ini
print_r($ini->data);

// Parse config.ini
$ini->read('config.ini');

// Remove item from second_section
unset($ini->data['second_section']['URL']);

// Remove third_section from second ini file and save to third file
unset($ini->data['third_section']);

// Save settings to new file
$ini->write('config-3.ini');

// INI obj is now using ini 3 file
// Content of: config-3.ini
print_r($ini->data);

  Files folder image Files  
File Role Description
Accessible without login Plain text file config.ini Data INI sample
Accessible without login Plain text file example.php Example Example script
Plain text file INI.class.php Class Class file
Accessible without login Plain text file README.md Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:1,320
This week:2
All time:2,925
This week:96Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:53%StarStarStar
Rank:2196