PHPIni (.ini)

Background & Context

    • 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.


Basic Examples  (9)

Export an association as a section with properties:

Create a file:

Add a section and an element to it:

Import it as a PHPIni file:

Create a file:

Write properties and comments to it:

Import the data only, as an Association:

Import the data and the commented lines:

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

PHPIni represents lists as a PHP array:

PHPIni represents associations as a PHP map:

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

Commented lines must start with the character ";":

Arbitrary expressions are converted to strings:

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

Introduced in 2017