1strcasecmp()
比较两个字符串(不区分大小写):
<?php
echo strcasecmp("shanghai","SHANGHAI");
?>
- 0 - 如果两个字符串相等
- <0 - 如果 string1 小于 string2
- >0 - 如果 string1 大于 string2
- 0echo strcasecmp("Hello world!","HELLO WORLD!")."<br>"; // 两字符串相等
7echo strcasecmp("Hello world!","HELLO")."<br>"; // string1 大于 string2
-7Echo strcasecmp("Hello world!","HELLO WORLD! HELLO!")."<br>"; // string1 小于 string2
2比较验证码
if(wiki_config('ENABLED_CAPTCHA')&&(empty($captcha)orstrcasecmp(session('milkcaptcha'),$captcha)!==0)){
比较2次输入的密码if(strcmp($password,$confirm_password)!==0)
3
account账号
4
empty($cookie)===falseorempty(session('member'))===false
$member=session('member');
$cookie['member_id']
5if(empty($password)||strlen($password)<5||strlen($password)>18){
if(mb_strlen($this->input['title'])>10){中文也算一个
// output('ROLE_TITLE_LONG');
// }
andmb_strlen($member->nickname)>20)
6
if(empty($email)||!filter_var($email,FILTER_VALIDATE_EMAIL)){
return$this->jsonResult(40503);
}
<?php
if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL))
{
echo("E-mail is not valid");
}
else
{
echo("E-mail is valid");
}
$member->member_passwd=password_hash($password,PASSWORD_DEFAULT);
$hash = password_hash($pwd, PASSWORD_DEFAULT);
哈希值创建完毕,我们可以用password_verify()来校验密码是否和哈希值匹配:
代码如下:
boolean password_verify ( string $password , string $hash )
8还得看看
$member->headimgurl=asset('/static/images/middle.gif');
99
if($member->member_id<=0andempty($member->account)){
thrownewArgumentNullException('账号不能为空',40507);
}
11000
if(empty(Member::where('email','=',$member->email)->where('member_id','<>',$member->member_id)->first())===false){
thrownewDataExistException('邮箱已存在',40509);
}
11
if(empty($member)orpassword_verify($password,$member->member_passwd)===false){
thrownewDataNullException('账号或密码错误',40401);
}
12日志
Logs::addLogs($logs,$member->member_id,$original_data,$present_data);
Public staticfunction addLogs($content,$user_id,$original_data=null,$present_data=null)
{
$logs=newLogs();
$logs->create_at=$user_id;
$logs->content=$content;
$logs->original_data=$original_data;
$logs->present_data=$present_data;
$logs->create_time=date('Y-m-dH:i:s');
return$logs->save();
}
13
try{
$result=Member::addOrUpdateMember($member);
if($result==false){
return$this->jsonResult(500);
}
$member=Member::login($account,$password);
session_member($member);
return$this->jsonResult(0);
}catch(\Exception$ex){
$message=$ex->getMessage();
if(empty($message)){
$message='系统错误';
}
return$this->jsonResult($ex->getCode(),null,$message);
}
}