PHP code example of tyurderi / hosts
1. Go to this page and download the library: Download tyurderi/hosts 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/ */
tyurderi / hosts example snippets
$editor = new tyurderi\Hosts\Editor();
// Create a new host entry
$host = $editor->push('127.0.0.1', 'example.com');
// Edit an existing host entry
$host = $editor->find('example.com');
echo $host->ip, PHP_EOL; // => 127.0.0.1
echo $host->hosts, PHP_EOL; // => example.com
echo $host->ignored, PHP_EOL; // => false
echo $host->empty, PHP_EOL; // => false
$host->ip = '127.0.0.2';
$host->remove();
$editor->write();