本文整理汇总了PHP中Random::number方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::number方法的具体用法?PHP Random::number怎么用?PHP Random::number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Random
的用法示例。
在下文中一共展示了Random::number方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: POST_phoneAction
/**
* 发送手机验证码
* @method POST_phoneAction
* @author NewFuture
*/
public function POST_phoneAction()
{
$response['status'] = 0;
if (!Input::post('phone', $phone, Config::get('regex.phone'))) {
$response['info'] = '手机号格式有误或者不支持!';
} elseif (!Input::post('account', $account, Config::get('regex.account'))) {
$response['info'] = '账号有误,如果账号忘记请联系云印工作人员';
} elseif (!($Printer = PrinterModel::where('account', $account)->field('id,phone')->find())) {
$response['info'] = '尚未注册';
} elseif (!Safe::checkTry('pwd_phone_' . $account)) {
$response['info'] = '尝试次数过多,临时封禁!';
} elseif (!$Printer['phone'] || $Printer['phone'] != $phone) {
$response['info'] = '绑定手机不一致,或者手机号错误';
} elseif (!Sms::findPwd($phone, $code = Random::number(6))) {
$response['info'] = '短信发送出错,请联系我们!';
} else {
/*发送成功*/
$find = ['id' => $Printer['id'], 'account' => $account, 'code' => strtoupper($code)];
Session::set('find_info_p', $find);
Safe::del('pwd_phone_' . $account);
$response['status'] = 1;
$response['info'] = '验证短信已发送';
}
$this->response = $response;
}
示例2: simulate
/**
* Simulates a trading period
*
* @param int $steps
* @param int $drift
* @param float $volatility
* @param bool $start
* @return $this
*/
public function simulate($steps = 8, $drift = 0, $volatility = 0.1, $start = false)
{
$price = $this->price;
if ($start) {
$price = $start;
}
$this->addRun($price);
//TODO CONSIDER GAPS
for ($i = 0; $i < $steps; $i++) {
$growth = exp($drift + $volatility * Random::number());
$price = round($price * pow($growth, 1 / $steps), 2);
$this->addRun($price);
}
$this->price = $price;
return $this;
}
示例3: POST_phoneAction
/**
* 绑定用户手机,发送验证码
* PUT /user/1/phone {phone:"13888888888"}
* @method GET_infoAction
* @param integer $id [description]
* @author NewFuture
*/
public function POST_phoneAction($id = 0)
{
$id = $this->auth($id);
$response['status'] = 0;
if (!Input::post('phone', $phone, 'phone')) {
$response['info'] = '手机号码无效';
} elseif (UserModel::getByPhone($phone)) {
$response['info'] = '已经绑定过用户';
} elseif (!Safe::checkTry('bind_phone_' . $id)) {
$response['info'] = '发送次数过多,稍后重试';
} else {
/*手机有效,发送验证码*/
$code = Random::number(6);
Session::set('code_phone', [$code => $phone]);
if (Sms::bind($phone, $code)) {
$response['status'] = 1;
$response['info'] = '发送成功[最多可重发5次]';
} else {
$response['info'] = '短信发送出错[最多可重发5次]';
}
}
$this->response = $response;
}
示例4: numberDec
/**
* 数字编码并按指定长度补位
* @param $num
* @param int $len
* @return string
*/
public static function numberDec($num, $len = 0)
{
$numStr = strval($num);
$slen = strlen($numStr);
$tagNo = '5';
//没有补位
$tagYes = '4';
// 已经补位 ,补位后第二个字符为补位长度
if ($len == 0) {
return $tagNo . self::to62($num);
}
if ($len <= $slen) {
return $tagNo . self::to62($numStr);
}
// 补位,补位长度不能操过62
$bl = $len - $slen;
$numStr = Random::number($bl) . $numStr;
return $tagYes . self::to62($bl) . self::to62($numStr);
}