I'm making function to insert some data into my database:
function updateInfo($company, $address, $postalnumber, $city, $phone, $email, $ip, $officehours, $etc){}
...and figured out i needed to set most of the parameters optional:
function updateInfo($company=NULL, $address=NULL, $postalnumber=NULL, $city=NULL, $phone=NULL, $email=NULL, $ip=NULL, $officehours=NULL, $etc=NULL){}
..until i figured out the parameter list became too long. So i discovered extract()
and made my parameter list an array of optionals instead:
function updateInfo($vars){
extract($vars);
}
Would you use extract()
this way, or is there better way to pass a lot of optional variables into a function?