$ record = new NS ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 "
]);
echo 'getHost = ' . $ record ->getHost () . PHP_EOL ;
echo 'getTtl = ' . $ record ->getTtl () . PHP_EOL ;
echo 'getClass = ' . $ record ->getClass () . PHP_EOL ;
echo 'getTypeName = ' . $ record ->getTypeName () . PHP_EOL ;
echo 'getTarget = ' . $ record ->getTarget () . PHP_EOL ;
getHost = ns.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = NS
getTarget = 192.168.0.1
$ record = new NS ();
$ record ->setData ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 "
]);
echo 'getHost = ' . $ record ->getHost () . PHP_EOL ;
echo 'getTtl = ' . $ record ->getTtl () . PHP_EOL ;
echo 'getClass = ' . $ record ->getClass () . PHP_EOL ;
echo 'getTypeName = ' . $ record ->getTypeName () . PHP_EOL ;
echo 'getTarget = ' . $ record ->getTarget () . PHP_EOL ;
getHost = ns.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = NS
getTarget = 192.168.0.1
$ record = Record ::fromString ('ns.bluelibraries.com 3600 IN NS 192.168.0.1 ' );
echo 'getHost = ' . $ record ->getHost () . PHP_EOL ;
echo 'getTtl = ' . $ record ->getTtl () . PHP_EOL ;
echo 'getClass = ' . $ record ->getClass () . PHP_EOL ;
echo 'getTypeName = ' . $ record ->getTypeName () . PHP_EOL ;
echo 'getTarget = ' . $ record ->getTarget () . PHP_EOL ;
getHost = ns.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = NS
getTarget = 192.168.0.1
Create from initialized array
$ record = Record ::fromNormalizedArray ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 " ,
'type ' => "NS "
]);
echo 'getHost = ' . $ record ->getHost () . PHP_EOL ;
echo 'getTtl = ' . $ record ->getTtl () . PHP_EOL ;
echo 'getClass = ' . $ record ->getClass () . PHP_EOL ;
echo 'getTypeName = ' . $ record ->getTypeName () . PHP_EOL ;
echo 'getTarget = ' . $ record ->getTarget () . PHP_EOL ;
getHost = ns.bluelibraries.com
getTtl = 3600
getClass = IN
getTypeName = NS
getTarget = 192.168.0.1
$ records = DNS ::getRecords ('ns.bluelibraries.com ' , RecordTypes ::NS );
print_r ($ records );
Array
(
[0] => BlueLibraries\Dns\Records\Types\NS Object
(
[data:protected] => Array
(
[host] => ns.bluelibraries.com
[ttl] => 3600
[target] => 192.168.0.1
[type] => NS
[class] => IN
)
)
)
$ dns = new DnsRecords ();
$ records = $ dns ->get ('ns.bluelibraries.com ' , RecordTypes ::NS );
print_r ($ records );
Array
(
[0] => BlueLibraries\Dns\Records\Types\NS Object
(
[data:protected] => Array
(
[host] => ns.bluelibraries.com
[ttl] => 3600
[target] => 192.168.0.1
[type] => NS
[class] => IN
)
)
)
Retrieve without helper, using custom handler settings
$ dnsHandler = new TCP ();
$ dnsHandler ->setRetries (2 );
$ dnsHandler ->setTimeout (3 );
$ dnsHandler ->setNameserver ('8.8.8.8 ' );
$ dns = new DnsRecords ($ dnsHandler );
$ records = $ dns ->get ('ns.bluelibraries.com ' , RecordTypes ::NS );
print_r ($ records );
Array
(
[0] => BlueLibraries\Dns\Records\Types\NS Object
(
[data:protected] => Array
(
[host] => ns.bluelibraries.com
[ttl] => 3600
[target] => 192.168.0.1
[type] => NS
[class] => IN
)
)
)
$ record = new NS ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 "
]);
echo 'string1 = ' . json_encode ($ record ->toString ()) . PHP_EOL ;
echo 'string2 = ' . json_encode ((string )$ record ) . PHP_EOL ;
string1 = "ns.bluelibraries.com 3600 IN NS 192.168.0.1"
string2 = "ns.bluelibraries.com 3600 IN NS 192.168.0.1"
$ record = new NS ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 "
]);
echo 'JSON = ' . json_encode ($ record ) . PHP_EOL ;
JSON = {"host":"ns.bluelibraries.com","ttl":3600,"target":"192.168.0.1","class":"IN","type":"NS"}
$ record = new NS ([
'host ' => "ns.bluelibraries.com " ,
'ttl ' => 3600 ,
'target ' => "192.168.0.1 "
]);
print_r ($ record ->toArray ());
Array
(
[host] => ns.bluelibraries.com
[ttl] => 3600
[target] => 192.168.0.1
[class] => IN
[type] => NS
)