Category Archives: Programming

Tips, tutorials and techniques surrounding programming in many languages such as PHP, MySQL, Javascript, jQuery and more.

PHP Script to Check Remote Server Port or Service is Running

As most webmasters will know, if your website is doing, clients are going to be knocking on your door with pitchforks and torches. Here is a script that allows you to monitor remote ports on a server to make sure that the required services are running such as Apache (port 80), FTP (port 21), SSH [...]

PHP Function To Quickly Implode Array Keys Into A String

In PHP there is a great function for converting a PHP Array into a string (and visa versa) using the function implode() as well as the array_keys() function to fetch the keys of the array. Combining these two functions, we can easily convert the keys of an array into a string. Note that as this [...]

PHP Function To Get File Mime Type

Whenever you need to determine the mime-type of a file you should generally look at the file extension. Below is a pretty straight forward function that will return the mime-type of a file based on its file extension. Note! this is not a guaranteed way to determine the mime-type since people can easily fake the [...]

Use PHP Headers to Force File Download

In apache, the file type will usually determine how the file is handled when viewing a website in our browser. For example, images, css, javascript, php, html (and other types) files are executed and displayed within the browser whereas PDF, ZIP, EXE and other unknown file types will be downloaded by the browser. Usually this [...]

Fastest way to format file size into kilobytes, megabytes and gigabytes

In this short post, you will find a PHP function that has got to be the quickest way to convert bytes into an easier to read format of kilobytes, megabytes, gigabytes and petabytes. The PHP filesize convert function takes the number (as bytes) passed to it and will convert it into an easier to read [...]