View Single Post
Old 11-30-2009, 08:48 PM   #12 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Assuming it wouldn't be easier to just rename the function for different uses (don't overload if you don't have to), if you were determined to use the same name you could always use a switch.

php Code:
$num  = func_num_args();
$args = func_get_args();

switch ( $num ) {
    case 1:
        some_func();
        break;

    case 2:
        some_other_func();
        break;
}

You could alternatively use count() on $args, or place your code where the some_funcs() are... same theory applies to overloading for the purposes of dealing with different objects,

php Code:
function fake_overload( $obj ) {

    if ( ! is_object( $obj ) )
        return;

    $reflect = new ReflectionClass( $obj );

    switch ( $reflect->getName() ) {
        case 'first_object': ...
delayedinsanity is offline  
Reply With Quote