views:

158

answers:

4

Possible Duplicate:
Common programming mistakes for PHP developers to avoid?

PHP is hated by a lot of programmers and even more hated is how the code is written by sloppy PHP coders.

What, according to you, are the basic things a PHP programmer must follow and things (s)he must never not do? Or give example(s) of the most common bad PHP code you've come across and what should have been done instead.

A: 

Without being a smart arse, did you try this? You will get a LOT of good resources. Basically, after reading 3-4 best practices lists, you will be able to extract what are NO NO things :)

Ionut Staicu
+3  A: 

Browse through the various posts on SO on what not to do.

This is what you should do .


Edit:
Also related.

Russell Dias
A: 

While writing code in PHP if you unintentionally (i.e) you may be unaware of spaces. It will provoke an error in PHP.

Wasim
I'm sorry, but this doesn't make any sense...
musicfreak
@Wasim: you may be referring to Python, not PHP.
BoltClock
@BoltClock's a Unicorn: maybe this was meant: "unintentional whitespace/BOM before the starting `<?php` raises the `headers already sent` warning when using `header()`"?. The crystal ball is a little hazy today ;)
Piskvor
A: 

You should sanitize user input!

Airjoe
That's one of biggest mistakes. Doing this "sanitization" mindlessly lead to numerous problems.
Col. Shrapnel
I didn't say to do it mindlessly, I said to sanitize user input, which should always be sanitized.
Airjoe
@Airjoe: the question was what ***not*** to do. Did you mean to say user input should not be sanitised? If not I suggest you change your answer.
Peter Mortensen
Good note, Peter, thanks.
Airjoe
@Airjoe: I think the answer should be inverted (if that was your real intention). As in; question: "What not to do in PHP?", answer: "Not sanitizing user input." (or "Forgetting to sanitize user input.")
Peter Mortensen