调用函数时有没有办法避免参数过多?
Eg:
function myFunction($usrName,$usrCountry,$usrDOB//and many more){
// Do something with all those arguments here
}
我这样做的一种方法是定义常量
//After thorough checking
$sesUserName = $_SESSION['sesUserName'];
define('USERNAME', $sesUserName);
myFunction(){
// Do something with USERNAME here
// No need to use USERNAME when calling the function
}
但是还有其他方法可以做到这一点吗?