本文整理汇总了PHP中randomNumber函数的典型用法代码示例。如果您正苦于以下问题:PHP randomNumber函数的具体用法?PHP randomNumber怎么用?PHP randomNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了randomNumber函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pageController
function pageController()
{
$data = [];
$data['adjective'] = randomAdjective();
$data['name'] = getServerName();
$data['number'] = randomNumber();
return $data;
}
示例2: generatePostalCode
function generatePostalCode($selected)
{
if (strcmp($selected, "United Kingdom") == 0) {
// this isn't exactly correct as there are rules about which letters can be used in which format, but structurally
// these cover it -- well, according to wikipedia at least http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Format
$variant = rand(0, 5);
switch ($variant) {
case 0:
// A9 9AA
$postalCode = randomCharacter() . randomNumber() . ' ' . randomNumber() . randomCharacter(2);
break;
case 1:
// A99 9AA
$postalCode = randomCharacter() . randomNumber(2) . ' ' . randomNumber() . randomCharacter(2);
break;
case 2:
// AA9 9AA
$postalCode = randomCharacter(2) . randomNumber() . ' ' . randomNumber() . randomCharacter(2);
break;
case 3:
// AA99 9AA
$postalCode = randomCharacter(2) . randomNumber(2) . ' ' . randomNumber() . randomCharacter(2);
break;
case 4:
// A9A 9AA
$postalCode = randomCharacter() . randomNumber() . randomCharacter() . ' ' . randomNumber() . randomCharacter(2);
break;
case 5:
// AA9A 9AA
$postalCode = randomCharacter(2) . randomNumber() . randomCharacter() . ' ' . randomNumber() . randomCharacter(2);
break;
}
} elseif (strcmp($selected, "United States") == 0) {
// zip5 and zip9
$variant = rand(0, 1);
// only does zip 5
$variant = 0;
switch ($variant) {
case 0:
// 12345
$postalCode = randomNumber(5);
break;
case 1:
// 12345-1234
$postalCode = randomNumber(5) . '-' . randomNumber(4);
break;
}
} elseif (strcmp($selected, "Canada") == 0) {
// A1A 1A1
$postalCode = randomCharacter() . randomNumber() . randomCharacter() . ' ' . randomNumber() . randomCharacter() . randomNumber();
}
return $postalCode;
}
示例3: changePassword
/**
* 重置密码
*/
public function changePassword()
{
$uid = I('id');
$map['uid'] = $uid;
$password = randomNumber();
$data['password'] = think_weiphp_md5($password);
if (M('User')->where($map)->save($data)) {
//如果带有参数 以U方法生成跳转URL
$this->success('重置成功密码为:' . $password, U('index'), 10);
} else {
$this->error('数据异常!');
}
}
示例4: getNewResetPassword
function getNewResetPassword($userId)
{
global $UserResetPassword;
$newResetPassword = randomNumber();
$resetPassword = new BOL_UserResetPassword();
$resetPassword->setUserId($userId);
$resetPassword->setExpirationTimeStamp(time() + 3600);
$resetPassword->setUpdateTimeStamp(time() + 600);
$resetPassword->setCode($newResetPassword);
$UserResetPassword->save($resetPassword);
return $resetPassword;
}
示例5: sendVerificationMail
function sendVerificationMail($type, $params)
{
global $getConfig;
global $getFeedback;
global $getRouter;
global $language;
global $getMailer;
global $EmailVerifyService;
$subject = $params['subject'];
$template_html = $params['body_html'];
$template_text = $params['body_text'];
switch ($type) {
case "user":
$user = $params['user'];
$email = $user->email;
$userId = $user->id;
break;
case "site":
$email = $getConfig->getValue('base', 'unverify_site_email');
$userId = 0;
break;
default:
$getFeedback->error($language->text('base', 'email_verify_verify_mail_was_not_sent'));
return;
}
$emailVerifiedData = $EmailVerifyService->findByEmailAndUserId($email, $userId, $type);
if ($emailVerifiedData !== null) {
$timeLimit = 60 * 60 * 24 * 3;
// 3 days
if (time() - (int) $emailVerifiedData->createStamp >= $timeLimit) {
$emailVerifiedData = null;
}
}
if ($emailVerifiedData === null) {
$emailVerifiedData = new BOL_EmailVerify();
$emailVerifiedData->userId = $userId;
$emailVerifiedData->email = trim($email);
$emailVerifiedData->hash = randomNumber();
$emailVerifiedData->createStamp = time();
$emailVerifiedData->type = $type;
$EmailVerifyService->batchReplace(array($emailVerifiedData));
}
$vars = array('code' => $emailVerifiedData->hash);
$language = $language;
$subject = UTIL_String::replaceVars($subject, $vars);
$template_html = UTIL_String::replaceVars($template_html, $vars);
$template_text = UTIL_String::replaceVars($template_text, $vars);
$mail = $getMailer->createMail();
$mail->addRecipientEmail($emailVerifiedData->email);
$mail->setSubject($subject);
$mail->setHtmlContent($template_html);
$mail->setTextContent($template_text);
$getMailer->send($mail);
if (!isset($params['feedback']) || $params['feedback'] !== false) {
$getFeedback->info($language->text('base', 'email_verify_verify_mail_was_sent'));
}
}
示例6: randomNumber
<?php
include '../inc/functions.php';
/* generate SKU number */
$sku = randomNumber(12);
echo $sku;
示例7: randomMessage
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
<script>
function randomMessage(data){
<?php
$random = randomNumber();
$user_query = "SELECT full_name FROM users where id = {$random} limit 1";
$users = fetch($user_query);
foreach ($users as $key => $user) {
$name = $user;
}
?>
var random = "<?php
echo $name;
?>
";
$("#chat_box").append("<p>" + random + ": " + data.message + "</p>");
}
$(document).ready(function(){
var socket = io.connect('http://localhost:5000');
var name = prompt("What is your name?");
示例8: Elaborate
public function Elaborate($requests)
{
$randBound = randomNumber(strlen("ff6a932f-7ca9-4926-9ae0-0e12776eacbf"));
$randBoundSub = randomNumber(strlen("ff6a932f-7ca9-4926-9ae0-0e12776eacbf"));
$boundary = "batchresponse_" . $randBound;
http_response_code(202);
//accepted
$result = "";
header("DataServiceVersion: 1.0;");
header("Content-Type: multipart/mixed; boundary=" . $boundary);
header("Cache-Control: no-cache");
//header("Content-Type: multipart/mixed");
//header("X-Content-Type-Options: nosniff");
//header("X-XSS-Protection: 1; mode=block");
for ($i = 0; $i < sizeof($requests); $i++) {
$request = $requests[$i];
$result .= "--" . $boundary . "\r\n";
$result .= "Content-Type: application/http\r\n";
$result .= "Content-Transfer-Encoding: binary\r\n";
$result .= "\r\n";
$result .= "HTTP/1.1 " . $request->ResultStatus . " ";
if ($request->ResultStatus == 200) {
$result .= "OK\r\n";
} else {
$result .= "KO\r\n";
}
$result .= "Cache-Control: no-cache\r\n";
$result .= "DataServiceVersion: 2.0;\r\n";
if (is_numeric($request->ResultData)) {
$result .= "Content-Type: text/plain;charset=utf-8\r\n";
} else {
$result .= "Content-Type: application/atom+xml;type=feed;charset=utf-8\r\n";
}
if ($request->ContentId != null) {
$result .= "Content-ID: " . $request->ContentId . "\r\n";
}
$result .= "Content-Length: " . strlen($request->ResultData) . "\r\n";
$result .= "\r\n";
$result .= $request->ResultData . "\r\n";
}
$result .= "--" . $boundary . "--\r\n";
//file_put_contents("batch.log","RESULT:\r\n".$result."\r\nENDOFRESULT", FILE_APPEND);
header("Content-Length: " . strlen($result));
echo $result;
flush();
return $result;
}
示例9: array
$xcrud->columns('id,name,description,brand,color,size,category,gender,img,price,active,rating,flag_featured,flag_bestseller,date_created');
$xcrud->fields('name,description,brand,color,size,category,gender,price,active,rating,flag_featured,flag_bestseller,img');
$xcrud->column_tooltip('img', 'Recommended size is 268x249');
$xcrud->label('flag_featured', 'Flag New Item');
$xcrud->change_type('rating', 'select', '', array('values' => array('0', '1', '2', '3', '4', '5')));
$xcrud->change_type('img', 'image', false, array('path' => '../uploads', 'thumbs' => array(array('height' => 249, 'width' => 268, 'crop' => true, 'marker' => '_th'))));
$xcrud->change_type('price', 'price', '', array('prefix' => 'Rp. '));
//$xcrud->set_attr('sku',array('readOnly'=>'True','id'=>'sku'));
//$xcrud->validation_required('sku');
$xcrud->validation_required('name');
$xcrud->validation_required('description');
$xcrud->validation_required('category');
$xcrud->validation_required('price');
$xcrud->validation_required('img');
//$xcrud->before_insert('update_sku');
$xcrud->pass_var('sku', randomNumber(12), 'create');
$xcrud->pass_var('date_created', Date('Y-m-d h:i:s'), 'create');
$xcrud->pass_var('last_updated', Date('Y-m-d h:i:s'), 'edit');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Administrator Page</title>
<?php
require_once '../inc/inc_header.php';
?>
<section id="main-content">
示例10: randomNumber
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Submit" name="submit">
</td>
</tr>
</table>
</form>
<div class="resultBox">
<h3><u>Result :</u></h3>
<p>
<strong>
<?php
if (isset($_POST['start_number'])) {
if ($_POST['start_number'] == 0) {
echo 'Sorry No Number Inputed';
} else {
echo 'The generated random password is - ' . randomNumber($start_number);
}
}
?>
</strong>
</p>
</div>
</div>
</body>
</html>