Best way to pass values to a function when there are many to send?

TPTP

New Member
What is the best way to define a method signature when you have to pass many values to a function and some of these may be optional. And in future, May be I have to pass more variables or subtract some passed values given to function.For example: (phone and address are optional)\[code\]function addInfo( $name, $dob, $phone='', $address='' ) { // Store data}addInfo( 'username', '01-01-2000', '1111111' ); // address is not given\[/code\]OR\[code\]function addInfo( $info ) { // Store data}$info = array( 'name'=>'username', 'dob'=>'01-01-2000', 'phone'=>'1111111', 'address'=>'' );addInfo( $info );\[/code\]
 
Back
Top