PHP code example of gemz / port

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

    

gemz / port example snippets

 php
use \Gemz\Port\Port;

$checks = new Port('gemz.io');
// or
$checks = Port::for('gemz.io');

// check all default ports on tcp
$checks = Port::for('gemz.io')->check();

// check specific ports on tcp
$checks = Port::for('gemz.io')->check(80, 8080, 443, 22, 3306, 9000, 9001);

// check only specific ports on tcp
$checks = Port::for('gemz.io')->useTcp()->check(80, 8080);

// check only specific ports on udp
$checks = Port::for('gemz.io')->useUdp()->check(110, 140);

// check only specific ports on tls
$checks = Port::for('gemz.io')->useTls()->check(443);

// check only specific ports on ssl
$checks = Port::for('gemz.io')->useSsl()->check(443);

// check with array for specific port => protocol checks
// if global setting will be ignored
$checks = Port::for('gemz.io')->useTcp()->check([80 => 'tcp', 2525 => 'udp', 443 => 'tls']);

// check with array for specific port 
$checks = Port::for('gemz.io')->useTcp()->check([80, 2525, 443]);

// set timeout, default is 0.5s
$checks = Port::for('gemz.io')->setTimeout(0.4)->check(80);

// get supported protocols
$protocols = Port::for('gemz.io')->getProtocols();

// get default ports
$ports = Port::for('gemz.io')->getDefaultPorts();

// get domain
$protocols = Port::for('gemz.io')->getDomain();