PHP code example of viirre / urlchecker

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

    

viirre / urlchecker example snippets




$url = 'http://www.google.com';
$checker = new \Viirre\UrlChecker\Checker();
$status = $checker->check($url);

if ($status->isRespondingOk()) {
    echo "Url {$url} is responding ok, woho!";
} elseif ($status->isRespondingButNotOk()) {
    echo "Url {$url} is responding, but with status code: " . $status->getStatusCode() . " and reason for not a 200: " . $status->getReason();
} elseif ($status->isNotResponding()) {
    echo "Url {$url} is NOT responding ok, fail reason: " . $status->getReason();
}

$timeInSeconds = $status->getTimeInSeconds();
$timeInMilliSeconds = $status->getTimeInMilliSeconds();

$response = $status->getResponse();

// Get protocol info from the response
$protocol = $response->getProtocolVersion();