News Feed
Jobs Feed
Sections




News Archive
Brandon Savage's Blog:
Be Wary of User Contributed Notes
November 23, 2009 @ 09:19:46

Brandon Savage has a reminder for both those familiar with PHP and a warning for those new to the language - take the examples in the comments of the PHP.net with a grain of salt.

This morning, I was reviewing the weekly list of topics with the most comments throughout the PHP manual, and I stumbled upon the following code in the documentation for the date() function. This code is designed to tell you the day of the week for any valid date you give it. [...] I'm sure that this user put a lot of work and effort into this function. I'm sure they were excited to share it with the PHP community. I'm sure they thought they had stumbled on a solution to a problem that everyone needed to solve. I'm sure they had no idea that this code is a great example of using PHP precisely the wrong way.

His example, one that uses around 30 lines of code to do something that date could accomplish in one, is a perfect example of why blindly following the advice of others without thinking things through can be disastrous for your code. Do a bit of research before you cut and paste and remember that with someone else's code could come someone else's problems - think before you implement.

0 comments voice your opinion now!
contributed notes advice opinion


blog comments powered by Disqus

Similar Posts

Hartmut Holzgraefe's Blog: PHPReboot Braindump

Clay Loveless' Blog: 5 Reasons Simple Cloud is a Dark Cloud

Cal Evans' Blog: Microsoft and PHP

Phil Sturgeon: Arguing on the Internet

Reddit.com: Can We Revive php.net User Notes Or Kill It?


Community Events











Don't see your event here?
Let us know!


release symfony2 podcast series functional conference framework opinion community usergroup testing interview zendframework2 language database introduction unittest development phpunit rest

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework