PHP code example of yggverse / net
1. Go to this page and download the library: Download yggverse/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/ */
yggverse / net example snippets php
var_dump(
\Yggverse\Net\Socket::isOpen('yo.index', 80)
);
php
var_dump(
\Yggverse\Net\Socket::isHost('yo.index')
);
php
var_dump(
\Yggverse\Net\Socket::isPort(80)
);
php
var_dump(
\Yggverse\Net\Dig::records('yo.index', ['A', 'AAAA'], &$result = [], &$error = [], $provider = null, $timeout = 5)
);
php
var_dump(
\Yggverse\Net\Dig::isHostName('yo.index')
);
php
var_dump(
\Yggverse\Net\Dig::isRecord('A')
);
php
var_dump(
\Yggverse\Net\Dig::isRecordValue('A', '127.0.0.1')
);
php
$resolve = new \Yggverse\Net\Resolve(
[
'A',
'AAAA'
],
[
'1.1.1.1',
'8.8.8.8'
],
// ..
);
php
$resolved = $resolve->address(
new \Yggverse\Net\Address(
'https://en.wikipedia.org/wiki/Domain_Name_System'
)
);
if ($resolved)
{
var_dump(
$resolved->get() // https://185.15.59.224/wiki/Domain_Name_System
);
var_dump(
$resolved->getHost() // 185.15.59.224
);
}
php
$base = new \Yggverse\Net\Address(
'http://yo.ygg/a1/b1/c1'
);
$address = new \Yggverse\Net\Address(
'/a2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://yo.ygg/a2
);
php
$base = new \Yggverse\Net\Address(
'http://user:[email protected] /a1/b1/c1?attribute=value#anchor'
);
$address = new \Yggverse\Net\Address(
'../../a2/b2?attribute2=value2#anchor2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://user:[email protected] /a2/b2?attribute2=value2#anchor2
);