PHP code example of volt / modern_php_scanner

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

    

volt / modern_php_scanner example snippets


    // an array of test links
    $a_urls = array(
        'http://www.pravda.com.ua',
        'http://www.xpravda.ua',
        'http://php.net/manual/ru/wrappers.php.php',
        'http://uberhumor.com/',
        'https://github.com/frankperez87/scanner/blob/master/src/Url/Scanner.php',
        'https://www.google.com.ua/maps/'
    );
    
    $o_scanner = new \Oreilly\ModernPhp\Url\Scanner($a_urls); // instantiate the component class
    
    $a_invalid_urls_arrays = $o_scanner->getInvalidUrls(); // get an array with resutls of scan 
    
    // print_r($a_invalid_urls_arrays);
    
    // == the end == 
    
    // the rest of the code below is compiling html markup for output in $c_html_url_result 
    // from array of arrays ($a_invalid_urls_arrays)
    
    $c_html_url_result = null;
    if (empty($a_invalid_urls_arrays)) {
        $c_html_url_result = "<h2>All provided URLs are valid</h2>";
    
    } else {
        $c_html_lis = null;
        
        foreach((array)$a_invalid_urls_arrays as $a_url_data){
            
            $c_url = array_key_exists('url', $a_url_data)? $a_url_data['url'] : 'N/A';
            $n_status_code = array_key_exists('status_code', $a_url_data)? 
                $a_url_data['status_code'] : 'N/A';
            
            $c_html_url = htmlspecialchars($c_url, ENT_QUOTES);
            $c_html_lis .= "<li><span>{$c_html_url}</span> Status message: <code>{$n_status_code}</code></li>";        
        }//endforeach
    
        $c_html_url_result = "<h2>The following URLs are invalid:</h2>"
            . "<ul>" . $c_html_lis . "</ul>";
    }//endif
    
    echo $c_html_url_result;
 bash 
$ composer