PHP code example of drewlabs / net

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

    

drewlabs / net example snippets


// Import abs\Net\Client;
use Drewlabs\Net\Method;

// Create a PING client
$client = new Drewlabs\Net\Pring(<HOST>, [<PORT>, <TMIEOUT>]);
// example
$client = new Drewlabs\Net\Pring('https://liksoft.tg');

// Send request using default Channel
$response = $client->request(); // Returns \Drewlabs\Net\PingResult class
// Send a Ping request using PHP fsockopen util
$response = $client->request(Method::FSOCKOPEN);


// Get response details
$response->latency(); // Returns the latency of the PING request
$response->ip(); // Returns the IP address of the client