当前位置: 首页>>代码示例>>PHP>>正文


PHP randomNumber函数代码示例

本文整理汇总了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;
}
开发者ID:cjsampson,项目名称:codeup.dev,代码行数:8,代码来源:server-name-generator.php

示例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;
}
开发者ID:PurdyForks,项目名称:saunter.php,代码行数:53,代码来源:Generators.php

示例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('数据异常!');
     }
 }
开发者ID:PunkAvail,项目名称:ThinkWechat,代码行数:16,代码来源:UserController.class.php

示例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;
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:12,代码来源:index_4_7_2015.php

示例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'));
    }
}
开发者ID:hardikamutech,项目名称:hammu,代码行数:57,代码来源:index_16_6_2015.php

示例6: randomNumber

<?php

include '../inc/functions.php';
/* generate SKU number */
$sku = randomNumber(12);
echo $sku;
开发者ID:rickyalex,项目名称:eshopper,代码行数:6,代码来源:get_sku_number.php

示例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?");
开发者ID:AndrewDoan,项目名称:php_node_sockets,代码行数:31,代码来源:index.php

示例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;
 }
开发者ID:roly445,项目名称:Php-Nuget-Server,代码行数:47,代码来源:batch.php

示例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">
开发者ID:rickyalex,项目名称:eshopper,代码行数:31,代码来源:items.php

示例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>
开发者ID:ipasa,项目名称:seip_php_17,代码行数:31,代码来源:example8.php


注:本文中的randomNumber函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。