Webmaster Tools

Webmaster Tools gives you a selection of utilities to help in designing your website. Tools include CSS color and font selection, drop down menu creation, code validation, meta-tag help, table creation, optimizers and simple encryption.

Click Here to access all of our online Webmaster Tools!

PHP Programming Tips


Turn On Error Reporting

error_reporting(E_ALL ^ E_STRICT);


Turn Off Error Reporting

error_reporting(0);


if/else Shortcut

if($varA == $varB){$valid = true;}else{$valid = false;}
$valid = ($varA == $varB ? true : false);


Create Random Password

function generate_passwd($length = 16){
    static $chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789';
    $chars_len = strlen($chars);
    for ($i = 0; $i < $length; $i++)
        $password .= $chars[mt_rand(0, $chars_len - 1)];
    return $password;
}


Date/Time Conversion

list($year, $month, $day) = split("-", $date);
$date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year));


Prevent Any Repetitions Of Characters

$str = preg_replace('{(.)\1+}','$1',$str);


Remove A URL/Link

$str = preg_replace('.*.*<\W*\/a\W*>', '[LINK REMOVED], $str');


Pre Define Variables

Bad Example

if($_POST['username'] == 'rob' && $_POST['password'] == 'foo'){
$authenticated = true; }

Good Example

$authenticated = false;
if($_POST['username'] == 'rob' && $_POST['password'] == 'foo'){
$authenticated = true;


Salt And Save An Md5 Password

$salt = 'thequickbrownfox';
$password 'foobar123';
$salted_hash = md5($salt . $password);


Pause Program Execution

sleep($ss); // $ss = number of seconds to wait

Content Copyright 2012 The USA Server Network/Imagelock West Communications
This Site Has Been Viewed 7476 Times Since Friday January 1st, 2010 And There Are 3 Visitors Currently Online

WSC Software Version 02.02.2011 - Copyright ©2010 By Imagelock West Communications All Rights Reserved