我得到這個錯誤,我不知道爲什麼。致命錯誤:調用未定義的函數 - codeigniter
我有產生隨機字符
function randomString($length) {
$len = $length;
$base = 'ABCDEFGHIJKLMNOPQRSTWXYZabcdefghıjklmnoprstwxyz123456789';
$max = strlen($base) - 1;
$activatecode = '';
mt_srand((double) microtime() * 1000000);
while (strlen($activatecode) < $len + 1)
$activatecode.=$base(mt_rand(0, $max));
return activatecode;
}
函數,我稱之爲
public function kayitBasarili() {
$this->load->view('kayitBasarili');
$username = $this->input->post('username');
$email = $this->input->post('email');
$password = $this->input->post('password');
$data = array();
$data['username'] = $username;
$data['email'] = $email;
$data['password'] = $password;
**$activationCode = $this->randomString(10);**
$this->load->view('kayitBasarili', $data);
$this->kayitmodel->uyeEkle($username, $email, $password,$activationCode);
}
這個功能爲什麼我得到這個錯誤?
用'**'圍繞函數做些什麼?相當肯定會造成問題 – 2012-02-27 09:14:23
它是加粗的功能,但不能在代碼視圖:) – 2012-02-27 09:15:17
Mert,你仍然需要返回'$ activatecode'。 :-)爲什麼不使用'substr(md5(microtime()。'somesalt'),0,10)'? – TerryE 2012-02-27 10:23:41