在我们的人力资源系统中,我给一个验证用户写了至少8个字母的注释。但是,如果他们不放,他们就不能插嘴。但他们正在做的是,他们有8个空格,他们可以输入:(所以我希望限制他们放置注意,避免空白。
if(empty($openPunch)){
$currentTime = $req->time;
if (strtotime($currentTime) >= strtotime('09:30')){
if(strlen($req->note) < 8){
$time = (strtotime($currentTime) - strtotime('09:30'));
$minutes = floor($time / 60);
$minute = $minutes%60;
$hours = floor($time / 3600);
return new IceResponse(IceResponse::ERROR,"Today you are late ".$hours.":".$minute." Hours You Can't Punch in without Fill the Correct Reason");
}
}
$openPunch = new Attendance();
}发布于 2016-07-22 05:32:29
使用trim()函数
函数从字符串的两边删除空格和其他预定义字符。
trim.asp
if(empty($openPunch)){
$currentTime = $req->time;
if (strtotime($currentTime) >= strtotime('09:30')){
if(strlen(trim($req->note)) < 8){
$time = (strtotime($currentTime) - strtotime('09:30'));
$minutes = floor($time / 60);
$minute = $minutes%60;
$hours = floor($time / 3600);
return new IceResponse(IceResponse::ERROR,"Today you are late ".$hours.":".$minute." Hours You Can't Punch in without Fill the Correct Reason");
}
}
$openPunch = new Attendance();
}发布于 2016-07-22 05:31:56
尝试像在W3 Schools js trim example中那样裁剪字符串
我没有特权发表评论,这就是为什么我把这个作为回答.
希望这能帮到你..。
同样,正如@Julie Pelletier评论的那样,它实际上并没有完全解决这个问题..!
谢谢..!
https://stackoverflow.com/questions/38518788
复制相似问题