Exemple #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
Exemple #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
Exemple #3
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"
Exemple #4
0
<?php

use com\selfcoders\pini\Pini;
use com\selfcoders\pini\Property;
use com\selfcoders\pini\Section;
require_once __DIR__ . "/../vendor/autoload.php";
$ini = new Pini();
$section = new Section("my section");
$section->comment = array("A section can contain a comment", "even over multiple lines");
$ini->addSection($section);
$section->addProperty(new Property("some key", "the value to save"));
$property = new Property("integer value", "12345");
$property->comment = array("This is a comment for the integer value property");
$section->addProperty($property);
$section = $ini->getDefaultSection();
$section->addProperty(new Property("some key", "this property is in the default section"));
$section = new Section("another section");
$ini->addSection($section);
$section->addProperty(new Property("my array", array(1, 2, 3, 4, 5)));
$ini->save(__DIR__ . "/example-write.ini");
Exemple #5
0
 public function testGetPropertyFromDefaultSection()
 {
     $ini = new Pini(__DIR__ . "/../../../examples/example.ini");
     $section = $ini->getDefaultSection();
     $this->assertEquals("value in default section", $section->getPropertyValue("some key"));
 }
Exemple #6
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