5 ways to write horribly ugly php code

Editors note:Yes, this post is just a little joke. Sometimes us developers just need to vent a little bit. Please don’t actually follow the advice in this post, kittens will die if you do.

Writing quality code these days is over rated. Why learn how to write proper php and coding when you can pick up a few tutorials online and start churning out security prone vomit code? Don’t let the professional developers fool you, the only reason they don’t write crappy code is because they have nothing better to do with their time! You have places to be don’t you? So why the hell would you spend so much time learning how to properly use php‽ It’s insane!

1. Don’t worry about errors, supress them!
Headers already sent? Screw you computer! I’ll tell you about my headers and errors! Instead of turning on error reporting while in development, just turn it off completely. This way you probably won’t have to worry about any annoying errors or things of that nature. If you do happen to get one of those annoying errors, simple supress is with the @ suppressor. Stick that in front of every function call and your code should have no errors at all!

If you still can’t figure out why you are getting errors, try rearranging the order of your code, putting things and function calls into different conditional statements. Don’t worry about any of the logic getting screwed up, someone else can fix that.

2. Use indecipherable variable and function names
Why spend and waste extra time making up and writing function and variable names when you can get right to the point? It’s not like anyone but you will ever read your code, and hell, you will surely remember!

Instead of something like this:

$user_name = try_user_login();//generic function call

Try something like this:

$a = z();//generic function call

Notice that we also saved some space by using short tags! Hell yea! Which brings me to my next point…

3. Use server specific settings
Always user short tags when writing with php. It doesn’t matter if it might not work on some poor souls server without changing some configuration file, they’re too dumb to know that short tags are teh best! Also be sure to never use the php echo function, instead use the short echo tags like so:

<?=$narwhalBaconsMidnight; ?>

4.Don’t comment anything!
Why waste time explaining why a certain class or method does what it does? Hell, we don’t even care what a class is! Save your time by not commenting anything, if someone else can’t figure out what you were trying to do, it’s not your fault, they’re just ignorant.

5. Drop those curly brackets!
Stop wasting so much space and so many lines when your writing php. Technically, the curly braces aren’t required for control structures, so there must not even be any point to them! Get rid of them now!

if($bacon === true)
    $vegan = false;
    generic_function_call();//May or may not get called, it's more fun that way!

Follow these steps and you are on your way to losing your job and becoming an art major. Best of luck!

Author: Drew Douglass


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: