【发布时间】:2012-02-27 17:51:27
【问题描述】:
我得到这个错误,我不知道为什么。
我有一个产生随机字符的函数
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);
}
为什么会出现这个错误?
【问题讨论】:
-
函数周围的
**是怎么回事?很确定这会导致问题 -
它是粗体功能,但在代码视图中不起作用:)
-
Mert,您仍然需要返回
$activatecode。 :-) 为什么不直接使用substr( md5( microtime() . 'somesalt' ), 0, 10)? -
激活码一定要用md5吗?
标签: php codeigniter