News Feed
Jobs Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Reddit.com:
Worst practices
September 04, 2013 @ 11:35:52

In this recent post to Reddit.com, people have been sharing some of the "worst practices" they've seen during their PHP development (or may even be guilty of).

For shits and giggles some colleagues and I are trying to write the crappiest PHP script we can think of, using as many bad practices as we can find. Alas, it's much harder then we thought, because we all have been trained to not do stupid stuff.

Things on the list so far include:

  • Multiple class definitions in a single file
  • Saving passwords unhashed and unencrypted in a database
  • Using a global variable inside a class to get a database connection
  • One letter variables
  • Pointlessly setting the signup method to being static
  • Using GET or POST vars directly from user input
  • Mixing HTML and PHP like there's no tomorrow.
  • make liberal use of extract() after running 'SELECT *'
  • Define a custom exception class for each class and only throw it from that class.
  • Make sure your DB connection is a singleton.
  • Throw ugly constants everywhere

What are some of the worst things you've seen? Share them here.

0 comments voice your opinion now!
worst practices opinion examples list

Link: http://www.reddit.com/r/PHP/comments/1lpgqk/worst_practices

Jason Lefkowitz's Blog:
The Worst Thing About PHP
June 01, 2006 @ 14:45:05

In his latest post, Jason Lefkowitz takes on something that's praised by PHP developers and non-PHP developers alike - the documentation for the project. There's just something he finds messy about the whole business.

Really, it has more to do with the way that PHP's structured than the actual documentation. It's just a case of art imitating life.

Now, having lots of libraries isn't necessarily bad - Java has an even more Herculean list. It only becomes a problem when you make no distinctions between them in the docs - like PHP.

PHP just throws a huge list of libraries at you and leaves you to figure out which one you need. There's no overarching "Database" package - instead you get Postgres functions and Oracle functions and Firebird functions and MySQL functions, all sprinkled throughout the list.

He also comments that the entire listing is also cluttered with other functionality, things that most developers would toss aside if they came across - they just don't need them.

His point isn't without merit - there is definitely a need to reorganize things in the manual to make them a bit more "topic friendly". The documentation is already one of the most well-maintained in the Open Source community, so the content is there, maybe it's just the structure that needs to be changed.

0 comments voice your opinion now!
worst thing documentation organized function worst thing documentation organized function



Community Events











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


security application symfony2 opinion install hack composer database series podcast component package unittest hhvm facebook language performance release introduction framework

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