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.
Read More: Laravel How To Pass Multiple Parameters into Route Tutorial
Let’s get started.
Check Domain Nameservers Using Terminal
Open system terminal and run this command.
$ whois onlinewebtutorblog.com | grep "Name Server"
Output
Let’s see in PHP programming.
Application 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
Read More: How To Add Custom Attribute in Laravel Model Tutorial
Output
We hope this article helped you to learn about Find NameServers of Domain Using PHP Shell Command in a very detailed way.
If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.