PHP code example of ilyagvc / checkhost

1. Go to this page and download the library: Download ilyagvc/checkhost 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/ */

    

ilyagvc / checkhost example snippets


$checkHost = new CheckHost(
    array|null $selectedCountries = null,
    bool $except = false,
    string|null $proxy = null,
    int $timeout = 60
);


use ILYAGVC\CheckHost\CheckHost;
 = $checkHost->runCheck('https://www.google.com', 'ping', 2);
print_r($result);

Array
(
    [host] => www.google.com
    [type] => ping
    [results] => Array
        (
            [Germany] => Array
                (
                    [result_summary] => Array
                        (
                            [ping]       => 4/4
                            [average_ms] => 1
                            ...
                        )
                        ...
                )
            [Iran] => ...
        )
)


use ILYAGVC\CheckHost\CheckHost;
 = $checkHost->fullCheck('https://www.google.com');
print_r($result);

Array
(
    [Austria] => Array
        (
            [ping]       => [...]
            [http]       => [...]
            [tcp]        => [...]
            [udp]        => [...]
            [dns]        => [...]
            [traceroute] => [...]
        )
        ...
)

$checkHost = new CheckHost(['Germany', 'AT']);

$checkHost = new CheckHost(['France'], true);

$checkHost->setProxy('http://127.0.0.1:8080');
$checkHost->setTimeout(10);