Skip to content

Simple PHP Form Error Class, Validate Errors Class, OOP

<?php      /**   Simple Error Class * *   – Define Error Messages, Regular Expressions *   – Log Errors to Error Array *   – Sanitize Input *   – Print/Display Errors […]

PHP Random String Generator Class, OOP.

 <?php class GenerateRandom{          /** Variable to be used by methods */     public $randomString = ”;     public $lenght;     public $characters;     public $charactersLength;      […]

Check if current PHP page name is the one you’re looking for.

 <?php /** Check if current page is a specific one we’re looking for */ function isPage($checkpage){          /** Check basename of the file     *   basename returns trailing […]

PHP MySQL Database Connection Class, OOP

  <?php /**  *  MySQL Database configuration settings  *  Database Constants  *  If constants are defined, CONNECT else, DEFINE CONSTANTS.  *  *  Fill Values below with your own DB Credentials […]

PHP Display YouTube Video Class, OOP. Embed YouTube Video.

 <?php /** *   YouTube video Class – display video *   Features(Briefly): *       – Check if video Exists *       – Set Video width, length, frameborder, allowfullscreen *       – Display YouTube Video […]

PHP Condition Statements: Shorthand, Nested, Inside function

 <?php /** Declare String Variable  */ $name = “Kwacho”; /** *   #1   *   Regular   */ if($name){     echo $name; } else {     echo “….Oopsy”; } /** *   […]

PHP Check Regular Expressions with preg_match()

<?php     //Simple Regex Matching code.     /** Regular Expression     *   accepts:     *       – upper & lower case letters from a to z     *       – numbers from […]

scp Secure Copy to remote host with Linux

// Copy testFile.php from remote host/machine to Localhost scp username@remote_host:/etc/practice/testFile.php ./   // Copy testFile.php from Localhost to remote host/machine scp testFile.php username@remote_host:/etc/practice     Explanation:

Get IP Addresses with ifconfig command

Max OS X ifconfig en0 | grep -i inet | awk ‘{print $2}’ | cut -f 2 -d ‘:’ Result 178.62.55.250   RedHat ifconfig eth0 | grep -i inet | […]

PHP function that accepts any number of arguments

<?php     /** Function accepting any number of arguments */     function manyArgsFunc(){           /**  Returns the number of arguments passed to the function */         $numOfArgs = func_num_args();   […]