Inside this article we will see the concept i.e Find NameServers of Domain Using PHP Shell Command. Article contains the classified information about Retrieving the name servers of a given domain with PHP.
There are several ways to get Nameservers of any domain. But in this tutorial we will see the use of PHP function shell_exec(). This is a very simple concept to learn and get to your code implementation.
Let’s get started.
Check Domain Nameservers Using Terminal
Open system terminal and run this command.
$ whois onlinewebtutorblog.com | grep "Name Server"
Let’s see in PHP programming.
Create a folder with name php-ns.
Next, create a file index.php inside it.
Open index.php and write this complete code into it.
<?php $whois = shell_exec('whois onlinewebtutorblog.com | grep "Name Server"'); $NsString = str_replace("Name Server: ", " ", $whois); //echo $NsString; echo "<pre>"; $NsArray = explode(" ", strtolower($NsString)); print_r(array_filter($NsArray));
Before running this shell command in your PHP environment, you need to make sure these:
- shell_exec should be enabled
- whois package should be available in your system
We hope this article helped you to learn about Find NameServers of Domain Using PHP Shell Command in a very detailed way.
Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.