Link To Full Story: www.sellmix.com
4: Do not trust your users!
90% of beginner PHP programmers trust their users. I may have completely made that statistic up – but I’m pretty sure it would be close enough to that figure. Sure, the majority of the people who will use your web application will be nice people who would never dream of damaging your website. However, all it takes is one a!*hole with enough knowledge about web applications to ruin the entire show. If you’re asking the user to enter a number, check that what they entered is actually a number. If you’re asking a user to enter their email address, check to make sure that what they entered was actually an email address.
5: Brackets – use them.
if($condition) //do something
The above piece of code may work etc, but it makes your code far less readable. Instead, you should always try to use full parenthesis:
if($condition){ //do something }
It just makes your code easier on the eye and gives it some structure, that’s all.
6 – The often liberal assignment of variables onto one another
When you are constantly assigning variables onto one another, you’re not only using up memory – you’re also making it difficult to track any bugs that might pop up:
require_once("inc/vars.php"); $tax_insurance = $total_tax; $cost = $tax_insurance + $other_variable; $another_cost = $cost + $other_variable; $cost = $another_cost; $goddamit = $another_cost;
Ugh.
Post a Comment