PHP function parse_ini_file() and example


 

PHP function parse_ini_file() and example

In this part of the tutorial we will learn about the function parse_ini_file() in context of file handling. And also we will see the example related to the parse_ini_file() function

In this part of the tutorial we will learn about the function parse_ini_file() in context of file handling. And also we will see the example related to the parse_ini_file() function

Syntax of PHP parse_ini_file() Function

  • It is used to parse ini file.ini.
  • file.ini is configuration file
  • After parsing it returns the settings of the ini file in array form


PHP parse_ini_file() Function with Example

Code For PHP parse_ini_file() Function

make a sample.ini with the content 

name = roseindia
domain= net
[second_section]
path = "/usr/local/bin"
URL = "http://www.roseindia.net"
[third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"

<?php
    $ar1
=parse_ini_file("sample.ini");
    foreach
($ar1 as $k=>$v)
      echo
$k."->".$v."<br/>";
?>

Output
name->roseindia
domain->net
path->/usr/local/bin
URL->http://www.roseindia.net
phpversion->Array

Ads