PHPIni (.ini)

Background

    • Configuration file format.
    • Associates keys to values.
    • Gathers elements into sections.
    • Can represent PHP expressions such as arrays or maps.
    • Configuration format for PHP application servers.
    • Plain text format.

Import & Export

  • Import["file","PHPIni"] returns a representation of a file as an Association.
  • Import["file",{"Ini",elem}] returns the specified data representation of a file.
  • Export["file.ini",expr] exports expr as an Ini file.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Data representation elements:
  • "Data"data as an association
    "DataRules"data as a list of rules
    "CommentedData"data as a list of sections as rules, comments as strings, and values as associations
  • The "PHPIni" format exports elements of an association or a list.
  • "PHPIni" treats an association as a list of sections. The keys specify the section names; the values specify the elements of a section as associations.
  • Lists in the Wolfram Language are represented in PHPIni as PHP arrays.
  • Associations in the Wolfram Language are represented in PHPIni as PHP maps.
  • The PHP symbols "On", "True" and "Yes" are imported as True. The PHP symbols "Off", "False" and "No" are imported as False.
  • "PHPIni" accepts lists containing a mixture of rules and strings. Rules are exported as sections; strings are exported as commented lines.
  • A commented line starts with ";".
  • Elements declared before the first section are associated with the key None.
  • "CommentedData" preserves inline comments; other data representations discard them.

Examples

Basic Examples  (9)

Export an association as a section with properties:

In[1]:=
Click for copyable input
Out[1]=

Create a file:

In[1]:=
Click for copyable input

Add a section and an element to it:

In[2]:=
Click for copyable input

Import it as a PHPIni file:

In[3]:=
Click for copyable input
Out[3]=

Create a file:

In[1]:=
Click for copyable input

Write properties and comments to it:

In[2]:=
Click for copyable input

Import the data only, as an Association:

In[3]:=
Click for copyable input
Out[3]=

Import the data and the commented lines:

In[4]:=
Click for copyable input
Out[4]=

If no section was defined, elements are associated to the key None:

In[1]:=
Click for copyable input
Out[1]=

PHPIni represents lists as a PHP array:

In[1]:=
Click for copyable input
Out[1]=

PHPIni represents associations as a PHP map:

In[1]:=
Click for copyable input
Out[1]=

Sections must start with the character "[" and finish with "]":

In[1]:=
Click for copyable input
Out[1]=

Commented lines must start with the character ";":

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Arbitrary expressions are converted to strings:

In[1]:=
Click for copyable input
Out[1]=

It is possible to build a PHPIni configuration file with commented elements:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2017
(11.1)