Beispiel #1
0
<?php

use com\selfcoders\pini\Pini;
require_once __DIR__ . "/../vendor/autoload.php";
$ini = new Pini(__DIR__ . "/example.ini");
$section = $ini->getSection("my section");
$property = $section->getProperty("some key");
echo $property->value;
// This will return "some value"
echo $section->getPropertyValue("some key");
// This will also return "some value"
echo $section->getPropertyValue("not existing key", "fallback value");
// This will return "fallback value" as the key does not exist
Beispiel #2
0
<?php

use com\selfcoders\pini\Pini;
require_once __DIR__ . "/../vendor/autoload.php";
$ini1 = new Pini(__DIR__ . "/example.ini");
$ini2 = new Pini(__DIR__ . "/example-merge.ini");
$ini1->merge($ini2);
$section = $ini1->getSection("another section");
$property = $section->getProperty("some key");
echo $property->value;
// This will return "another value" from the merged ini
Beispiel #3
0
 public function testGetNotExistingPropertyValueWithDefault()
 {
     $ini = new Pini(__DIR__ . "/../../../examples/example.ini");
     $section = $ini->getSection("my section");
     $this->assertEquals("fallback value", $section->getPropertyValue("not existing key", "fallback value"));
 }
Beispiel #4
0
<?php

use com\selfcoders\pini\Pini;
require_once __DIR__ . "/../vendor/autoload.php";
$ini1 = new Pini(__DIR__ . "/example.ini");
$ini2 = new Pini(__DIR__ . "/example-merge.ini");
$section = $ini1->getSection("my section");
$property = $section->getProperty("some key");
echo $property->value . "\n";
// This will return "some value"
$ini1->merge($ini2);
echo $property->value . "\n";
// This will still return "some value" as the instance of the old property won't be touched, instead the new property instance of the second ini will be added
$section = $ini1->getSection("my section");
$property = $section->getProperty("some key");
echo $property->value . "\n";
// This will return "replaced value"
Beispiel #5
0
<?php

use com\selfcoders\pini\Pini;
require_once __DIR__ . "/../vendor/autoload.php";
$ini = new Pini(__DIR__ . "/example.ini");
$section = $ini->getSection("arrays");
$property = $section->getProperty("myarray");
var_dump($property->value);
// This will return an array containing 3 values