Among senior developers, PHP is often seen as a tool for non-complex applications and rapid programming environments that may never be launched. I’m going to discuss the reasons for this, and things PHP developers can do to change this perception.
I wanted to write this article to give both my opinions and observations since I started using PHP in the mainstream business world. Lots of people have a poor view of PHP and its usage for business applications and complicated development sites. I’m going to explain why individuals and other website developers have this misconception and ways that PHP developers can improve their coding so that these myths can be forgotten.
One of the main reasons PHP is seen in a poor light is due to programmer inexperience. PHP is the next logical step for a web designer after they learn CSS and HTML because the barrier to entry is so low. Servers and inexpensive and the majority of designers and developers can easy use PHP scripts on their servers without any type of installation or configuration. This means that a higher percentage of new programmers and developers are using PHP, thus they may be using poor coding standards and bad practices.
Why So Loose?
PHP is a loosely typed language, which means that developers must be very careful when evaluating and comparing variables, because of this reason, new programmers (and even experienced developers from other languages) will have a difficult time writing effective code that evaluates properly.
$myNum1 = 1; $myNum2 = '1'; if ($myNum1 == $myNum2) echo 'Hey, they're equal! Well not really because one is an integer and another a string, BUT WHO CARES!'; if ($myNum1 === $myNum2) echo 'Hey, they're NOT equal! And this time, I'm right!';
Developer Coding Standards
Best practices are often something that inexperienced developers don’t follow, mostly because they don’t know that they exist. The majority of PHP programmers will follow the Zend guidelines for best programming practices. If a company you go to work for does not follow the Zend coding standard guidelines, they surely will know about them, and you will easily be able to transfers this knowledge to whatever they are using. Its not so much about choosing which standards are right, but more about weeding out the poor standards that virtually everyone agrees on.
My List Of The Most Common Errors / Inefficiencies
- Placing database calls and code within presentation and logic code
- Note reusing code (See my introductory tutorial on developing in OOP with PHP)
- Not filtering user input
- Copying internet tutorial code and not reviewing it
- Not planning to scale or understanding how to
- Using a framework without first understanding the raw language
What These Errors Cause
- Exploits, such as SQL injection and cross-site scripting
- Cluttered code that slows down future development
- Debugging difficulties
How To Improve The Misconceptions
- Learn about caching both database calls and your code
- Figure out how to sanitize input
- Learn programming fundamentals and standards
- Make sure PHP is the right tool for the job
New developers are often the reasons for PHP having such a bad reputation with big business. Experienced programmers can write excellent PHP code that is more efficient and effective than other popular web programming languages, however the ability for anyone to start writing PHP code has been both a blessing and a curse upon the language.
Developers will often read a framework’s site and see promises like ‘Improve your development time by 50%!’. Well, all seems great, except that inexperienced programmers will take this to heart before they even start writing real PHP code, which often-times leads to a bloated code-base.
PHP Is Slow
This is true. PHP is a language that will always need to utilize caching on all projects with high traffic, however this problem is not PHP specific. If your’re developing a high traffic PHP application, you need to research memcached.
Other Things To Remember When Developing PHP Code
PHP was created as a web templating engine, it was not meant to be an all-encompassing language. You should understand this before beginning to develop with it. What framework should I use? I hear Smarty is great! What about Codeigniter? First off, if you really need to ask which is the BEST, you probably have no clue how to actually use these tools to your advantage and should really stick with PHP until you have a firm understanding of it. Second, most developers critize templating engines like Smarty, because PHP was initially created as a web templating engine, so you going to template the template? Well, thats another topic all-together.
If you’re getting into PHP, I hope that this article has helped you to gain some understanding of areas that you should place some time when learning to develop PHP scripts and applications.



2 Comments
Great article. Informative and to the point.
Indeed the barrier to entry using PHP is low. And it does tend to attract beginners. Because PHP is inherently insecure, it certainly can be (and has been) a problem. Even though I do agree that someone should grasp the language before picking up a framework (say Codeigniter,) I think that perhaps it’s not such a bad idea to use a framework as some security issues are abstracted away when using built in code. Or security measures can be easily turned on in the framework. I’ll take bloated, inefficient code any day over easily-exploited code.
Thanks for the input Bretticus. I actually had not thought much about that, but since you mentioned it I believe it is a valid point. I need to amend the article to include your input! =D