PHP constants vs variables

The differences between constants and variables in PHP isn’t enormous but here they are: A constant cannot be changed once set and constants are global so unlike variables they can…

MySQL rollback with PHP PDO

Roll back a MySQL transaction with the PDO rollBack() function. All that is needed is beginTransaction. Start a transaction and run a query that modifies a table: $db->beginTransaction(); $update =…

Convert and format Bytes PHP function

A simple PHP function to convert and format Bytes to Megabytes, Gigabytes and Terabytes: function convertBytes(int $bytes, string $convert_to = ‘KB’, bool $format = true, int $decimals = 2): float…