Category Archives: PHP

Bulk Optimizing Images with ImageMagick

The article discusses bulk optimizing images using ImageMagick, a powerful open-source image manipulation tool. The author provides a step-by-step guide on installing and using the software to resize, compress and enhance multiple images simultaneously, reducing their size without compromising quality. The article also includes various command-line examples for different scenarios, such as batch resizing, compression, and format conversion. It is a valuable resource for optimising many images for their website or digital project.

ROT13 Encoder Source Code

The ROT13 encoder is a fun programming exercise that my students enjoyed recently. I have included my source code here in PHP and C. PHP <?php   function rot13($char)   {     $ascii = ord($char);     if (($ascii >= 65) && ($ascii <= 90))     {       $val = ($ascii – 51) % 26;       if ($val == 0)       {         $val = 26;       }       $val += 64;     }     else if (($ascii >= 97) && ($ascii <= 122))      {       $val = ($ascii – 83) % 26;       if ($val == 0)       {         $val = 26;       }       $val += 96;     }     else     {       $val = $ascii;     }     return (chr($val));   }   function main()   {… Read More »

Sanitising User Form Input Before Processing in PHP

Sanitising user form input before processing the data is an IMPORTANT security step to prevent malicious input wreaking havoc on your program or other unsuspecting users. The function below can take the $_POST array as input and return it sanitised for use. function cleanse($input) { // Clean the input before use to make sure we don’t… Read More »