有人可以帮我如何将数组的值更改为变量吗?
我想从这个改变:
class SimpleAuth
{
var $users = array(
'admin1' => 'password1', //
'admin2' => 'password2', // User 2
'admin3' => 'password3', // User 3
'admin4' => 'password4', // User 4
);
}
至:
$user = 'admin'; // value from an include file outside the class declaration
$password = 'password'; // value from an include file outside the class declaration
class SimpleAuth
{
var $users = array(
$user => $password, // User 1 // here is the error
'admin2' => 'password2', // User 2
'admin3' => 'password3', // User 3
'admin4' => 'password4', // User 4
);
}
我收到 500 错误。请帮忙!谢谢