PHP code example of cgtag / php-disposable
1. Go to this page and download the library: Download cgtag/php-disposable library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cgtag / php-disposable example snippets
$ composer
use cgTag\Disposable\IDisposable;
class ResourceHolder implements IDisposable {
private $file;
public function __constructor(string $filename) {
$this->file = fopen($filename, "r");
}
public function read() {
return stream_get_contents($this->file);
}
public function dispose() {
if($this->file) {
fclose($this->file);
}
$this->file = null;
}
}
using(new ConfigReader("config.ini"), function(ConfigReader $reader) {
$debug = $reader->get('debug');
});