For developers building PHP-backed Web applications, there may come a time when you'll need to interface with networking-layer functions such as ping and traceroute. The problem, of course, is that these aren't built right into PHP, so you have to find a module that emulates these common networking functions.
One easy solution lies in the PHP Extension and Application Repository (PEAR), which contains a number of PHP classes to accomplish these tasks. This series of articles will delve into the PEAR Net/* hierarchy to explain how to perform common network-layer tasks.
Ping a remote host to see if it's alive
We'll explain what is perhaps the most basic of networking functions: using the Net_Ping class to ping a remote site and make sure it's responding as it should.
Retrieve specific ping statistics
Once you're mastered the basics of Net_Ping, you'll probably want to extract some human-readable data from the response packet. Thankfully, this class supports a bunch of additional methods for extracting ping data.
Run a traceroute to a remote host
Based on the Net_Ping class, Net_Traceroute allows you to trace the route between your server and a remote host. And it's a cinch to use.
Obtain DNS records
If you need to obtain DNS information, the Net_DNS class is for you. But the records it returns are a lot more detailed than what you get from Net_Ping and Net_Traceroute. Here's how to make sense from the jumble of data.



