Function overloading in PHP

A while back i wrote somewhere:

After doing some Java, i do miss “overloading” a function. I hope they will implement it in PHP6… Overloading is creating two functions with same name, but have different amount off arguments passed to them… I did find a trick to go around, using a combination of func_num_args and func_get_args.

Last week i was working on a project in C# and tried to set a default value for a param, but got a error “Default parameter specifier is not permitted”. It was then i realized that PHP do have overloading, and it is done by supplying default values to parameters when defining a function.

By defining:

And it will gives access to:


Leave a Reply