<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <title>Example file of the class ParseINI</title> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
</head> 
 
<body> 
 
<?php 
 
// Path to the example ini file 
(string) $file = "example.ini"; 
 
// Include the class file 
include_once('parseini.class.php'); 
 
try { 
    // You can also define the class properties in the class constuctor 
    // (object) $ini = new ParseINI(array('file' => $file, 'quote' => '"')); 
 
    // Create new ini object 
    (object) $ini = new ParseINI(); 
 
    // Set the class properties like file and quote 
    $ini->setVar('file', $file); 
    $ini->setVar('quote', '"'); 
 
    // parse the defined inifile 
    (array) $data = $ini->parse(); 
 
    // Output 
    echo "<hr/>\n"; 
    if (isset($data['general']['host']) && isset($data['general']['ipaddr'])) 
        echo "All Services for ".$data['general']['host']." (".$data['general']['ipaddr'].")<br/>\n"; 
    if (isset($data['general']['description'])) 
        echo "Description: ".$data['general']['description']."<br/>\n"; 
    echo "<hr/>\n\n"; 
 
    if (isset($data['services'])) { 
        echo "<h3>There are ".count($data['services'])." services defined</h3>\n\n"; 
        echo "<table border=\"1\">\n"; 
        echo "\t<tr>\n"; 
        echo "\t\t<th>Service</th>\n"; 
        echo "\t\t<th>Port</th>\n"; 
        echo "\t</tr>\n"; 
        foreach ($data['services'] as $service) { 
            echo "\t<tr>\n"; 
            echo "\t\t<td>".$service['name']."</td>\n"; 
            echo "\t\t<td>".$service['port']."</td>\n"; 
            echo "\t<tr>\n"; 
        } 
        echo "</table>\n"; 
    } 
 
} catch ( Exception $error ) { 
    echo "Error: ".$error->getMessage()." on Line: ".$error->getLine()." in ".$error->getFile()."<br/>\n"; 
} 
 
?> 
 
</body> 
</html> 
 
 |