當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Random::get方法代碼示例

本文整理匯總了PHP中Random::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Random::get方法的具體用法?PHP Random::get怎麽用?PHP Random::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Random的用法示例。


在下文中一共展示了Random::get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: GenerateRandomPrintableString

 function GenerateRandomPrintableString($len = 10)
 {
     $o1 = new Random("23456789ABCDEFGHJKMNPQRSTUVWXYZ");
     return $o1->get($len);
 }
開發者ID:aldrymaulana,項目名稱:cmsdepdagri,代碼行數:5,代碼來源:FrontEndUsers.module.php

示例2: rolltype

    public function rolltype($dietype)
    {
        if (is_numeric($dietype)) {
            $newval = Random::get(1, $dietype);
        } elseif ($dietype == 'f') {
            $newval = Random::get(-1, 1);
        } elseif ($dietype == '%') {
            $newval = Random::get(1, 100);
        } elseif ($dietype[0] == '[') {
            $dietype = trim($dietype, '[]');
            $opts = explode(',', $dietype);
            $newval = $opts[Random::get(0, count($opts)-1)];
        } else {
            var_dump($dietype);
            $newval = 'unknown';
        }

        return $newval;
    }
開發者ID:ringmaster,項目名稱:dicecalc,代碼行數:19,代碼來源:CalcDice.php

示例3: get

 /**
  * Generate random characters
  *
  * @access  public
  * @param   int      $len   Length of the string you want generated
  * @return  string   Random characters
  */
 function get($len)
 {
     if (!(is_int($len) && $len > 0)) {
         return $this->_vcrs;
     }
     $ret = "";
     $cnt = strlen($this->_vcrs) - 1;
     for ($i = 0; $i < $len; $i++) {
         $ret .= $this->_vcrs[rand(0, $cnt)];
     }
     if ($this->_vnum || $this->_vnot) {
         return $this->_rec($ret, $this->_vnum, $this->_vnot) ? $ret : Random::get($len);
     } else {
         return $ret;
     }
 }
開發者ID:aldrymaulana,項目名稱:cmsdepdagri,代碼行數:23,代碼來源:class.Random.php

示例4: testExceptionIfAskedForMoreThen20Chars

 /**
  * @expectedException ShortCode\Exception\UnexpectedCodeLength
  */
 public function testExceptionIfAskedForMoreThen20Chars()
 {
     Random::get(25, Code::FORMAT_NUMBER);
 }
開發者ID:GasWagen,項目名稱:short-code,代碼行數:7,代碼來源:RandomTest.php

示例5:

                                    <td><span id="my_random_integer_number_2">&nbsp;</span></td>
                                </tr>
                                <tr>
                                    <td><pre><code>var my_unique_id = $.random.uuid();</code></pre></td>
                                    <td><span id="my_unique_id">&nbsp;</span></td>
                                </tr>
                            </tbody>
                        </table>

                    </div>

                    <div class="col-md-6">

                        <h4>PHP Implementation Tests</h4>
<?php 
$my_random_number = Random::get();
$my_random_integer_number = Random::integer(10);
$my_random_integer_number_2 = Random::integer_between(10, 19);
$my_unique_id = Random::uuid();
?>
                        <table class="table table-bordered" style="table-layout: fixed; word-wrap: break-word;">
                            <tbody>
                                <tr>
                                    <td style="width: 50%;"><pre><code>$my_random_number = Random::get();</code></pre></td>
                                    <td><?php 
echo $my_random_number;
?>
</td>
                                </tr>
                                <tr>
                                    <td><pre><code>$my_random_integer_number = Random::integer(10);</code></pre></td>
開發者ID:patilstar,項目名稱:HMVC-WITH-CI,代碼行數:31,代碼來源:random.php

示例6: testCodeGeneratedWithCorrectFormat

 /**
  * @dataProvider formatProvider
  *
  * @param $format
  * @param $formatName
  */
 public function testCodeGeneratedWithCorrectFormat($format, $formatName)
 {
     $code = Random::get(6, $format);
     $length = strlen($code);
     $this->assertSame(1, preg_match("/[{$format}]{" . $length . '}/', $code), 'Trying with ' . $formatName);
 }
開發者ID:GasWagen,項目名稱:short-code,代碼行數:12,代碼來源:ReversibleTest.php


注:本文中的Random::get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。