note that you can't have optional args passed by reference so you can't do &$optional_arg='' etc otherwise ...
PHP Code:
<?
function blah( $arg1 , $optional_arg='' , $optional_arg2='' ){
if( !empty( $optional_arg ) ){
//do_stuff//
}
}
blah( 'yaks' ) ;
blah( 'yaks' , 'yaks' ) ;
blah( 'yaks' , '' , 'yaks' ) ;
?>
this can get confusing sometimes so I like to use null when not passing an arg (so all calls at least look the same)
blah( 'yaks' , null , 'yaks') ;
but then you should be checking for is_null() within your function
And some will say the above is bad juju , perhaps thats true , I am now in the habit of passing a optional array of data instead , this makes things far easier to refactor if you need to another argument to a common function at some future point and do not want to trawl your code changing function calls to do so
PHP Code:
<?
$optional_args = array('arg2'=>'blah','arg3'=>'blah') ;
blah('yaks' , $optional_args ) ;
?>