企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` /** * 唯一日期编码 * @param integer $length * @return string */ public static function uniqidDateCode($length = 14) { if ($length < 14) $length = 14; $string = date('Ymd') . (date('H') + date('i')) . date('s'); while (strlen($string) < $length) $string .= rand(0, 9); return $string; } ``` ``` //手机号验证 function is_phone($phonenumber) { if (preg_match("/^1[23456789]{1}\d{9}$/", $phonenumber)) { return true; } else { return false; } } ``` ``` /** * 验证银行卡号 * @param string $bankCardNo 银行卡号 * @return bool 是否合法(true:合法,false:不合法) */ function checkBankCard($bankCardNo) { $strlen = strlen($bankCardNo); if ($strlen < 15 || $strlen > 19) { return false; } if (!preg_match("/^\d{15}$/i", $bankCardNo) && !preg_match("/^\d{16}$/i", $bankCardNo) && !preg_match("/^\d{17}$/i", $bankCardNo) && !preg_match("/^\d{18}$/i", $bankCardNo) && !preg_match("/^\d{19}$/i", $bankCardNo)) { return false; } $arr_no = str_split($bankCardNo); $last_n = $arr_no[count($arr_no) - 1]; krsort($arr_no); $i = 1; $total = 0; foreach ($arr_no as $n) { if ($i % 2 == 0) { $ix = $n * 2; if ($ix >= 10) { $nx = 1 + ($ix % 10); $total += $nx; } else { $total += $ix; } } else { $total += $n; } $i++; } $total -= $last_n; $x = 10 - ($total % 10); if ($x != $last_n) { return false; } return true; } ``` ``` function lastTime($time,$secondflag = true){ $diff = $time - time(); if($diff <= 0) return '0天0时0分'; $day = intval($diff/24/3600); $hour = intval( ($diff%(24*3600))/3600 ); $minutes = intval( ($diff%(24*3600))%3600/60 ); $second = $diff%60; if($secondflag){ return $day. '天' . $hour . '时' .$minutes. '分' .$second. '秒'; }else{ return $day. '天' . $hour . '时' .$minutes. '分'; } } ```