You should only store things in variables if your going to use them more than once, otherwise you are just wasting RAM by holding data in a variable that you will never use again. It may not seem like a big deal if you only coding small scripts, but you should really get into the habit of making your scripts lean and fast.
Bad Pratice:
Code: Select all
$time = time();
$sql = "INSERT INTO table (time) VALUES ('$time')";
mysql_query($sql);Solution:
Code: Select all
mysql_query("INSERT INTO table (time) VALUES ('".time()."')");Just my 2 cents there.
Any other views on the matter? Or other pratices that people should use? Look forward to hearing them.