PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Eper Kalman   M_INI   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example script
Class: M_INI
Create and parse .INI configuration files
Author: By
Last change:
Date: 12 years ago
Size: 851 bytes
 

Contents

Class file image Download
<?php

    error_reporting
(E_ALL);

    echo
'<br><font color="green">Test file before changes</font><br>';

    echo
nl2br(file_get_contents('test.ini'));

    include_once(
'M_INI.class.php');

   
$CONF = new M_INI();

   
# Uncheck to use quotes
    # $CONF -> use_quotes();

   
if (! $CONF->load('test.ini')) exit('File not found.');

   
$CONF->change('section1', 'value2', 'changed');
   
$CONF->remove('section1', 'value3');
   
$CONF->add('section2', 'value2', 'val2', 'Added by INI php class :');
   
$CONF->add('section3', 'value1', 'val1', 'Added by INI php class :');
    if (!
$CONF->save()) echo 'Cannot save file. Check permissions.<br>';

    echo
'<br><font color="green">Changed value of section1 value2 : '.$CONF->get('section1', 'value2').'</font><br>';

    echo
'<br><font color="green">Test file after changes</font><br>';

    echo
nl2br(file_get_contents('test.ini'));

?>