PHP Classes

Ini files

Recommend this page to a friend!

      PHP INI Read, Write and Edit  >  All threads  >  Ini files  >  (Un) Subscribe thread alerts  
Subject:Ini files
Summary:Could this be of help to you to extend your class abilties?
Messages:2
Author:Chris Sprucefield
Date:2016-05-19 20:32:40
 

  1. Ini files   Reply   Report abuse  
Picture of Chris Sprucefield Chris Sprucefield - 2016-05-19 20:32:40
I have written a class on a similar matter,

Advanced PHP .INI file reader.

Sections such as [ abc:def ] will be expanded as $var['abc']['def']

Names such as a.b.c and a:b:c will be expanded into sublevels.

A defined variable, can be referenced in dot notation, and used for substitution, such as:

root = "/mnt/some/path"
logs.access = "{root}/access_log"

Following this, logs.access will be "/mnt/some/path/access_log",
and ca be further referred to as {logs.access} for substitution.

$var['logs']['access'] = "/mnt/some/path/access_log" ;

Multiple elements can be referred, such as: myvar = "The root is {root}, and full path is {logs.access}"


Please note - If you do recursive variable substitutions, you are on your own buddy! =)

A part of a name can be literal, (uninterpreted) by surrounding it in '', such as
a.b.c.'abc.def' = "value" --> ['a']['b']['c']['abc.def'] = "value".

It was recently extended with capabilities such as:

#include <filename> Includes the file <filename>
#define <name> <value> Defines the constant <name> to be <value>, where value is the rest of the line.
#iniset <name> <value> Sets the ini parameter <name> to be <value>, where value is the rest of the line.


phpclasses.org/package/9292-PHP-Rea ...

Perhaps you have further ideas on what can be added, and if you want to use functionality, be my guest.

  2. Re: Ini files   Reply   Report abuse  
Picture of Lukasz Józwiak Lukasz Józwiak - 2016-05-30 16:09:34 - In reply to message 1 from Chris Sprucefield
Hi,
Yeap I understood, but Ini is simple one dimential text db, mostly used for config files. For things like You show i use json.
I write this class years ago, because php don't write ini it self.
Best Regards ydk2