PHP code example of hugsbrugs / php-http

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

    

hugsbrugs / php-http example snippets



use Hug\Http\Http as Http;

define('PDP_PDO_DSN', 'mysql:host=localhost;dbname=database');
define('PDP_PDO_USER', 'username');
define('PDP_PDO_PASS', 'password');
define('PDP_PDO_OPTIONS', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

define('PUBLIC_SUFFIX_LIST', realpath(__DIR__ . '/../../../cache/public_suffix_list.dat'));

Http::nslookup($url);

Http::is_url_accessible($url);

Http::get_http_code($url);

Http::url_remove_query($url);

Http::url_remove_query_and_path($url);

Http::grab_image($url, $save_to);

Http::get_default_headers($host);

Http::extract_all_from_url($url);

Http::extract_extension_from_url($url);

Http::extract_scheme_from_url($url);

Http::extract_tld_from_url($url);

Http::extract_subdomain_from_url($url);

Http::extract_domain_from_url($url);

Http::extract_request_headers_body($html_with_headers);

Http::header_status($statusCode);

Http::get_redirect_url($url, $timeout = 5, $return = 'url');

Http::get_all_redirects($url);

Http::get_final_url($url, $return = 'url');

Http::check_txt_record($domain, $txt);

Http::wait_for_zone_ok($domain, $ip, $txt_record, $wait_minutes = 15);

Http::is_zone_ok($domain, $ip, $txt_record);

Http::get_name_servers('maugey.fr');

Http::add_escaped_fragment($url);

Http::cors();

Http::url_2_filename($url);