Now that the hard sell is over and you're (hopefully) all set up with patSysinfo, let's take a simple example to see how it works.
Here's the output:
Let's dissect this to see how it works. 1. The first step is, obviously, to include all the relevant files for the class to work.
Once that's done, I can safely create an object of the patSysinfo class.
This object instance will serve as the central source for all system information, allowing me to do all kinds of nifty things with it. 2. Next, the object's getHostName() and getHostIp() methods are used to obtain the system's host name and IP address respectively.
Most of the patSysinfo API calls look like this: the word "get" followed by the information that is required. In the example above, the object first looks up the file "/proc/sys/kernel/hostname" for the current hostname, and then obtains the IP address using the host name and the gethostbyname() PHP function 4. Finally, all that's left is to actually use the data retrieved by the methods - in this case, print it all to the standard output device.
blog comments powered by Disqus |