How to Tail a File with PHP
This code will allow you to tail a file in PHP. It is cheating a little bit though because it is actually making a system call to tail, so you have to have tail installed. It is meant for Linux machines not Windows.
Advertisement
Advertisement
This code will allow you to tail a file in PHP. It is cheating a little bit though because it is actually making a system call to tail, so you have to have tail installed. It is meant for Linux machines not Windows.
cURL is a great library for transferring data over a number of network protocols. Unfortunately, it can be a little overwhelming to use for the first time in PHP and there are lots of options available. Here is an easy reference for using cURL in PHP.
In PHP, all command line arguments, including the script name itself are stored in a special array named $argv. The first element, zero, is the name of the script being run. For example:
XMPP/Jabber is a communication protocol typically used for chat servers. Nathan Fritz wrote a PHP library for XMPP called XMPPHP. These examples demonstrate how to use the library in PHP.
SSL sockets are perfect for sending secure data. With certificates, you can verify the identify of the host, the client, or both. Signed certificates cost money but you can create and self-sign a certificate. Check out the code samples below to see how to generate SSL certificates and create SSL clients and servers. Examples include raw socket communication as well as the common HTTPS protocol.
With PHP, creating a TCP server takes only a few lines of code. Check out this code that creates a server which responds with the current time.
PHP has a built in web server that was introduced in version 5.4.0. It is not suited for production but is great for easy development or quick testing. Here are a few ways to use it.
Using the Net_Nmap library, we can perform nmap scans using PHP. Here is a demonstration of how to do a basic scan and handle the results.
Two common libraries for image manipulation with PHP are GD and Imagick. GD typically comes with most PHP setups. Here are some code snippets that demonstrate how to crop an image with both libraries.
Git operations can be performed programmatically with PHP using the libgit2 library. Here are some common operations.
Advertisement
Advertisement