It’s because of the lack of decent documentation, and tutorials.
Unfortunately, you’ve hit the nail on the head. PHP is largely a chronic beginner’s language for just this reason.
php.net is your best, most reliable source. It is indispensable; but it is also less a tutorial than a reference manual. (and don’t put too much stock in the comment sections.)
Almost anything else you find should be taken with a big grain of salt until you get to a level of semi-proficiency where you can start to distinguish between good|crap.
One good thing I was introduced to recently is PHP the Right Way. I wish this had been around when I was learning.
I personally feel that the language feels “bolted together.”
Certainly was. PHP was not “designed” in any real sense of the word… it was basically thrown together as a highly task-specific scripting syntax and web utility for C. Over the years, it has not so much “evolved” as had more stuff “tacked on” to it. Good stuff coexists with bad in the name of backwards-compatibility. Object Oriented Programming is now a very real capability (PHP even has closures now …of a sort). While it is now a very nice, powerful language, when used carefully, there is admittedly still much sadness.
How did you learn PHP?
Where are you at in your learning? do you understand the syntax, variable types, scope? how to use functions? how to use objects? what other programming languages do you know, and how well do you know them?
Couple things off the top of my head:
- use recent PHP versions. 5.2.x and lower are unsupported, have serious unfixed problems, and should never be used. 5.3 isn’t really that great either.
- never trust your users. this is a programming-in-general rule, but is particularly overlooked by PHP coders. validate everything that comes in; sanitize everything that goes out.
- use unicode (UTF-8) (everywhere).
- indent your code. use comments if something is remotely not obvious. do not use abbreviations.
- never use
!=); always use
- always use
}(even though they are “optional” for single-line
- never use
@. by extension, never ignore errors: search them out, make them impossible to ignore, and then fix them. (while the
@operator actually does have legitimate uses, most coders will never encounter these cases and instead treat it as a magical error correction operator.)