有人可以帮助我如何将数组的值更改为变量?在数组中使用变量
我想从:
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错误。请帮忙!由于
你能显示错误吗?来自php错误日志的错误 – DevZer0
我得到的唯一错误是因为'var'。 – andrewsi
看看你的服务器错误日志 - 应该告诉你出了什么问题。 – 2013-07-02 15:20:38