SQLite is a relational database that stores data in memory or in a single portable file. These code snippets demonstrate how to use SQLite with PHP. One thing to note about exec verus query: the first executes a result-less query, and the latter performs a query that returns results. It is better to use a prepared statement than a query though. It is easier, safer, and will use less memory.
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:
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.
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.