To The New PHP Programmers…
Out Of Date Warning
Languages change. Perspectives are different. Ideas move on. This article was published on October 9, 2009 which is more than two years ago. It may be out of date. You should verify that technical information in this article is still current before relying upon it for your own purposes.
- Avoiding Notices: When to Use isset() and empty()
- Configuring PHP: Essential INI Settings
- Accessing Databases with PDO: A Primer
- To The New PHP Programmers…
- How To Write A Function In PHP
- Five Cool PHP Array Functions
- Micro Optimizations That Don’t Matter
- Adapting The Joel Test To Web Development
- Exceptional PHP: Introduction to Exceptions
- Suhosin: The Invisible Hand Of PHP
- Why You Should Replace ENUM With Something Else
Nearly five years ago I started writing PHP code for fun. I had a project that I was working on, and I needed some sort of a programming language that would do calculations for me, and hopefully make managing a website easier. So I wrote my first web application.
Boy, was it bad.
Looking back at it today, I have to laugh about the naive way I relied on things like register_globals and magic_quotes_gpc. Or about how I was frustrated by the fact that magic_quotes_gpc escaped things, and had to work my SQL queries so that they would work right. Or about how I used addslashes() to “escape” data.
Every day, new people join the PHP world, writing their first “hello world” script and moving on from there to connect to databases, build CRUDs, and otherwise explore the PHP language. If you’re one of them, you shouldn’t feel inadequate. No, learning PHP is a learning process. One of PHP’s strengths is that it is easy to learn, and that anyone can learn how to do it. Fewer can learn how to do it properly, but for those that do learn how to do it right, it can be a powerful language and a solid tool.
I’ve spent some time writing about beginner issues, and implementing The Beginner Pattern, because I think it’s important to help new developers to the community get better. But if you don’t understand everything, that’s ok. Ask for help, read the blogs and the manual, and keep writing code. A smart person once said that if you look at your code six months from now and think it’s ok, you’re doing something wrong.
In all of that, please also remember to be careful. PHP is a powerful language, with abilities that, if not checked with security concerns, can threaten an entire system. Learn all you can about security. Remember to Filter Input, Escape Output.
Those of us that have been doing PHP for a long time seem to have forgotten what it was like to be new at the language. For those that are new, please don’t become discouraged. PHP needs you, because the generation that comes next will replace the generation that is here now, and that’s how the project keeps moving forward.