有人可以幫助我如何將數組的值更改爲變量?在數組中使用變量
我想從:
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