The Montoya Herald, a weblog about Blueprint, jQuery, design, music and life, publishing on the web since September 2005. Written by Christian Montoya: developer, designer and entrepreneur.

The Montoya Herald — ChristianMontoya.com

Search

I Recommend

Genesis Rocket

Like What I Do?

My Amazon.com Wish List

On this domain

Elsewhere

Never again

Posted on November 11, 2008.

From now on, all my object constructors in PHP are going to use an associative array as the only argument. Since PHP doesn't support Java-style method overloading by signature (proof here), there's no other way to write methods that are flexible about their arguments. Sure, this will result in a lot of if(isset())s in my methods, but these are the concessions I make with PHP.

Get a trackback link

1 Comments

  1. Aleem Bawany on November 13, 2008

    This sounds very much like a JavaScript approach but in any case I don't see how this will allow you to overload based on the signature and resolve the original problem. Not only that but this will also cause you grief should you decide to generate API docs or use a PHP IDE with autocomplete etc. down the line.

Leave a comment

Use Markdown or basic HTML. For posting code, use Postable. Please keep comments respectful and on topic.