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


PHP Rand::getInteger方法代码示例

本文整理汇总了PHP中Zend\Math\Rand::getInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Rand::getInteger方法的具体用法?PHP Rand::getInteger怎么用?PHP Rand::getInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Math\Rand的用法示例。


在下文中一共展示了Rand::getInteger方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveOrder

 public function saveOrder(Order $order)
 {
     $order->id = Rand::getInteger(100000, 999999);
     $this->getEventManager()->trigger('preOrder', __CLASS__);
     $filePath = realpath(BIG5_ROOT . '/data/order') . '/';
     $fileName = $filePath . $order->id . '.txt';
     file_put_contents($fileName, serialize($order));
     echo "Save order " . $order->id . "<br />";
     $this->getEventManager()->trigger('postOrder', __CLASS__);
 }
开发者ID:dulumao,项目名称:big5,代码行数:10,代码来源:OrderService.php

示例2: populatePerson

 private function populatePerson(PersonEntity $person)
 {
     $genders = [0, 1, 2, 9];
     $gender = $genders[Rand::getInteger(0, count($genders) - 1)];
     $person->setGender($gender);
     $person->setJobTitle('Software Engineer');
     $person->setDepartment('Department');
     if ($gender === 2) {
         $person->setMaidenName('Maiden name');
     }
     $person->setNickname('Nickname');
 }
开发者ID:zource,项目名称:zource,代码行数:12,代码来源:Contact.php

示例3: formRand

 public function formRand()
 {
     $bytes = Rand::getBytes(32, true);
     $this->data->bytes = "Random bytes (in Base64): " . base64_encode($bytes);
     $boolean = Rand::getBoolean();
     $this->data->boolean = "Random boolean: " . ($boolean ? 'true' : 'false');
     $integer = Rand::getInteger(0, 1000);
     $this->data->integer = "Random integer in [0-1000]: " . $integer;
     $float = Rand::getFloat();
     $this->data->float = "Random float in [0-1): " . $float;
     $string = Rand::getString(32, 'abcdefghijklmnopqrstuvwxyz', true);
     $this->data->string = "Random string in latin alphabet:" . $string;
     $this->render();
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:14,代码来源:zendController.php

示例4: generateWord

 /**
  * Generate new random word
  *
  * @return string
  */
 protected function generateWord()
 {
     $word = '';
     $wordLen = $this->getWordLen();
     $vowels = $this->useNumbers ? static::$VN : static::$V;
     $consonants = $this->useNumbers ? static::$CN : static::$C;
     $totIndexCon = count($consonants) - 1;
     $totIndexVow = count($vowels) - 1;
     for ($i = 0; $i < $wordLen; $i = $i + 2) {
         // generate word with mix of vowels and consonants
         $consonant = $consonants[Rand::getInteger(0, $totIndexCon, true)];
         $vowel = $vowels[Rand::getInteger(0, $totIndexVow, true)];
         $word .= $consonant . $vowel;
     }
     if (strlen($word) > $wordLen) {
         $word = substr($word, 0, $wordLen);
     }
     return $word;
 }
开发者ID:zendframework,项目名称:zend-captcha,代码行数:24,代码来源:AbstractWord.php

示例5: generateCode

 public function generateCode()
 {
     // Generate code_public
     $private = Rand::getInteger(100000, 999999);
     // Generate code_private
     // Without 0 o
     $public = Rand::getString(6, 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789', true);
     // Set values
     $result = array('public' => $public, 'private' => $private);
     return $result;
 }
开发者ID:pi-module,项目名称:event,代码行数:11,代码来源:Order.php

示例6: roll

 public function roll()
 {
     return Rand::getInteger(1, 6);
 }
开发者ID:KasaiDot,项目名称:php-diceware,代码行数:4,代码来源:ZendDice.php

示例7: testIntegerRangeFail

 public function testIntegerRangeFail()
 {
     $this->setExpectedException('Zend\\Math\\Exception\\DomainException', 'min parameter must be lower than max parameter');
     $rand = Rand::getInteger(100, 0);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:5,代码来源:RandTest.php

示例8: getInteger

 /**
  * Generate random integer value
  *
  * @param integer $min lowest value to be returned
  * @param integer $max highest value to be returned
  * @return integer
  */
 public function getInteger($min, $max)
 {
     return \Zend\Math\Rand::getInteger($min, $max);
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:11,代码来源:Random.php

示例9: testIntegerRangeOverflow

 public function testIntegerRangeOverflow()
 {
     $values = 0;
     $cycles = 100;
     for ($i = 0; $i < $cycles; $i++) {
         $values += Rand::getInteger(0, PHP_INT_MAX);
     }
     $this->assertFalse($values === 0);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:9,代码来源:RandTest.php

示例10: testCanFindLatestVersion

 public function testCanFindLatestVersion()
 {
     $projectTest = new ProjectTest();
     /**
      * @var $project Project
      */
     $project = $projectTest->provider()[0][0];
     $project->setProject("This is a testProject . " . Rand::getString(6));
     $project->setNumber(Rand::getInteger(10000, 99999));
     $project = $this->projectService->newEntity($project);
     $this->projectService->getOptions()->setConsiderFppOnlyAsOfficialVersion(false);
     $this->projectService = $this->projectService->setProject($project);
     $latestVersion = $this->projectService->getLatestProjectVersion();
     $this->assertInstanceOf('Project\\Entity\\Version\\Version', $latestVersion);
 }
开发者ID:debranova,项目名称:project,代码行数:15,代码来源:ProjectServiceTest.php

示例11: __construct

 public function __construct()
 {
     $this->token = Rand::getInteger(1, self::MAX_TOKEN);
 }
开发者ID:beaucal,项目名称:beaucal-long-throttle,代码行数:4,代码来源:Handle.php


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