• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP getrandmax函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getrandmax函数的典型用法代码示例。如果您正苦于以下问题:PHP getrandmax函数的具体用法?PHP getrandmax怎么用?PHP getrandmax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: index_action

 /**
  * Displays the ngglegacy thumbnail gallery.
  * This method deprecates the use of the nggShowGallery() function.
  * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery
  */
 function index_action($displayed_gallery, $return = FALSE)
 {
     // Get the images to be displayed
     $current_page = (int) $this->param('nggpage', 1);
     if ($images = $displayed_gallery->get_included_entities()) {
         // Get the gallery storage component
         $storage = $this->object->get_registry()->get_utility('I_Gallery_Storage');
         // Create parameter list for the view
         $params = $displayed_gallery->display_settings;
         $params['storage'] =& $storage;
         $params['images'] =& $images;
         $params['displayed_gallery_id'] = $displayed_gallery->id();
         $params['current_page'] = $current_page;
         $params['effect_code'] = $this->object->get_effect_code($displayed_gallery);
         $params['anchor'] = 'ngg-slideshow-' . $displayed_gallery->id() . '-' . rand(1, getrandmax()) . $current_page;
         $gallery_width = $displayed_gallery->display_settings['gallery_width'];
         $gallery_height = $displayed_gallery->display_settings['gallery_height'];
         $params['aspect_ratio'] = $gallery_width / $gallery_height;
         $params['placeholder'] = $this->object->get_static_url('photocrati-nextgen_basic_gallery#slideshow/placeholder.gif');
         // Are we to generate a thumbnail link?
         if ($displayed_gallery->display_settings['show_thumbnail_link']) {
             $params['thumbnail_link'] = $this->object->get_url_for_alternate_display_type($displayed_gallery, NGG_BASIC_THUMBNAILS);
         }
         $params = $this->object->prepare_display_parameters($displayed_gallery, $params);
         $retval = $this->object->render_partial('photocrati-nextgen_basic_gallery#slideshow/index', $params, $return);
     } else {
         $retval = $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return);
     }
     return $retval;
 }
开发者ID:kiangkuang,项目名称:IHG1415,代码行数:35,代码来源:adapter.nextgen_basic_slideshow_controller.php


示例2: __construct

 /**
  * Constructor
  *
  * Instantiate the CSRF form element object.
  *
  * @param  string $name
  * @param  string $value
  * @param  int    $expire
  * @param  string $indent
  * @return \Pop\Form\Element\Csrf
  */
 public function __construct($name, $value = null, $expire = 300, $indent = null)
 {
     // Start a session.
     if (session_id() == '') {
         session_start();
     }
     // If token does not exist, create one
     if (!isset($_SESSION['pop_csrf'])) {
         $this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
         $_SESSION['pop_csrf'] = serialize($this->token);
         // Else, retrieve existing token
     } else {
         $this->token = unserialize($_SESSION['pop_csrf']);
         // Check to see if the token has expired
         if ($this->token['expire'] > 0) {
             if ($this->token['expire'] + $this->token['start'] < time()) {
                 $this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
                 $_SESSION['pop_csrf'] = serialize($this->token);
             }
         }
     }
     parent::__construct('hidden', $name, $this->token['value'], null, $indent);
     $this->setRequired(true);
     $this->setValidator();
 }
开发者ID:akinyeleolubodun,项目名称:PhireCMS2,代码行数:36,代码来源:Csrf.php


示例3: testHighLoad

 public function testHighLoad()
 {
     $nItems = array();
     $max = (double) getrandmax();
     for ($i = 0; $i < self::MAX; $i++) {
         $nItems[] = $this->buildMarker('marker_' . $i, 58 + $this->getRandomOffset($max), 24 + $this->getRandomOffset($max));
     }
     //        $start = microtime(true);
     //        $clustered = $this->c->clusterOriginal($nItems, 100, 11);
     //        $stop = microtime(true);
     //        $this->assertTrue($stop - $start < 21);
     //        printf("Cluster end in %f seconds\n", $stop - $start);
     //        $count = count($clustered);
     //        $this->assertTrue($count < self::MAX && $count > 1);
     //        unset($count);
     //        unset($clustered);
     //        unset($start);
     //        unset($stop);
     $start = microtime(true);
     $clustered = $this->c->cluster($nItems, 100, 11);
     $stop = microtime(true);
     $this->assertTrue($stop - $start < 21);
     $count = count($clustered);
     $this->assertTrue($count < self::MAX && $count > 1);
     printf("Cluster end in %f seconds\n", $stop - $start);
     var_dump($clustered);
 }
开发者ID:alvarops,项目名称:Clusterer,代码行数:27,代码来源:CoreTest.php


示例4: randomPastelColor

function randomPastelColor()
{
    $red = (double) rand() / (double) getrandmax() * 150 + 105;
    $green = (double) rand() / (double) getrandmax() * 150 + 105;
    $blue = (double) rand() / (double) getrandmax() * 150 + 105;
    return "#" . dechex($red) . dechex($green) . dechex($blue);
}
开发者ID:jjmpsp,项目名称:iamavailablefor.work,代码行数:7,代码来源:image_helper.php


示例5: initializeGlobals

 /**
  * @todo keep a documentation record of globals
  */
 protected static function initializeGlobals()
 {
     //initialize globals
     static::$globals = new \stdClass();
     static::$globals->{'rand-integer'} = function ($max = null) {
         if ($max === null) {
             $max = getrandmax();
         } else {
             $max = intval($max);
         }
         return rand(0, $max);
     };
     static::$globals->{'rand-string'} = [Util::class, 'readableRandomString'];
     static::$globals->{'rand-hash'} = function () {
         return sha1(rand() . mt_rand() . rand());
     };
     static::$globals->{'rand-boolean'} = function () {
         return (bool) rand(0, 1);
     };
     static::$globals->{'timestamp'} = function () {
         return time();
     };
     static::$globals->{'microtime'} = function ($get_as_float = false) {
         return microtime((bool) $get_as_float);
     };
 }
开发者ID:phramework,项目名称:testphase,代码行数:29,代码来源:Globals.php


示例6: test

function test()
{
    // Tests sccp into a binop
    // { phc-option: -O1 --dump=codegen }
    // Check propagation into bin_ops
    // { phc-regex-output: /5 </ }
    $const = 5;
    if ($const < rand()) {
        print `echo 5`;
        // side-effecting
    } else {
        print `echo 5`;
        // side-effecting
    }
    // Check propagation into unary ops
    // { phc-regex-output: !/\$const2/ }
    $const2 = 6;
    if (!$const2 && rand()) {
        print `echo 5`;
        // side-effecting
    } else {
        print `echo 5`;
        // side-effecting
    }
    // Check that dead vars that go through PHIs are removed
    // { phc-regex-output: !/\$const3/ }
    // Check that getrandmax is optimized out
    // { phc-regex-output: !/getrandmax/ }
    while ($argv[3] > getrandmax() / 2) {
        $const3 = "string";
        print `echo {$const3}`;
    }
    // Check we've removed all the !s
    // { phc-regex-output: !/!/ }
}
开发者ID:michaelprem,项目名称:phc,代码行数:35,代码来源:sccp1.php


示例7: beforeSendRequest

 function beforeSendRequest(Event $event)
 {
     $secondsPerConnection = 1 / $this->connectionsPerSecond;
     $secondsPerConnection *= 2 * rand() / getrandmax();
     // Distribute parallel connections
     usleep($secondsPerConnection * 1000000);
 }
开发者ID:frosas,项目名称:guzzle-plugins,代码行数:7,代码来源:ConnectionRate.php


示例8: random

 public function random($min = 0, $max = null)
 {
     if ($max === null) {
         $max = getrandmax();
     }
     return rand($min, $max);
 }
开发者ID:netcon-source,项目名称:prontotype,代码行数:7,代码来源:Utils.php


示例9: buildFile

 public static function buildFile($file, $dir, $name)
 {
     $doc_root = $_SERVER["DOCUMENT_ROOT"];
     $num = getrandmax();
     $date = date("Y-m-d H:i:s");
     $new_name = md5($num . $name . $date);
     $file->move($doc_root . "/photos/" . $dir, $new_name . "." . $extFile);
 }
开发者ID:giovanimora0527,项目名称:sigeri,代码行数:8,代码来源:FileMaker.php


示例10: enterObject

 function enterObject()
 {
     $this->setValue(substr(md5(microtime() . rand(1000, getrandmax())), 0, 6));
     $this->params['value_pool']['email'][$this->getName()] = stripslashes($this->getValue());
     if ($this->getElement(2) != 'no_db') {
         $this->params['value_pool']['sql'][$this->getName()] = $this->getValue();
     }
 }
开发者ID:VIEWSION,项目名称:redaxo_yform,代码行数:8,代码来源:generate_password.php


示例11: next

 public function next($context = null)
 {
     if (rand() / getrandmax() < $e) {
         return $this->explore();
     } else {
         return $this->exploit();
     }
 }
开发者ID:vinamilvinamil,项目名称:Learning-Library-for-PHP,代码行数:8,代码来源:EpsilonBandit.php


示例12: getRowGenerationOptions

 public function getRowGenerationOptions($generator, $postdata, $colNum, $numCols)
 {
     if (empty($postdata["dtOptionMean_{$colNum}"]) && $postdata["dtOptionMean_{$colNum}"] !== "0" || empty($postdata["dtOptionSigma_{$colNum}"]) && $postdata["dtOptionSigma_{$colNum}"] !== "0") {
         return false;
     }
     $this->randMax = (double) getrandmax();
     return array("mean" => $postdata["dtOptionMean_{$colNum}"], "stddev" => $postdata["dtOptionSigma_{$colNum}"]);
 }
开发者ID:balmychan,项目名称:generatedata,代码行数:8,代码来源:NormalDistribution.class.php


示例13: initWeights

 function initWeights()
 {
     for ($i = 0; $i < $this->numHidden; $i++) {
         $this->weightsHO[$i] = (rand() / getrandmax() - 0.5) / 2;
         for ($j = 0; $j < $this->numInputs; $j++) {
             $this->weightsIH[$j][$i] = (rand() / getrandmax() - 0.5) / 5;
         }
     }
 }
开发者ID:0-php,项目名称:AI,代码行数:9,代码来源:multilayerperceptron.class.php


示例14: random_string

/**
 * Create a random string.
 * DO NOT USE THIS FOR PASSWORDS AND SUCH!
 * @param int $length - Length of the string.
 */
function random_string($length = 32)
{
    $count = ceil($length / 40);
    $string = '';
    for ($i = 0; $i < $count; $i++) {
        $string .= sha1(rand(0, getrandmax()) . $string);
    }
    return substr($string, 0, $length);
}
开发者ID:WoutervdBrink,项目名称:PWS-Community,代码行数:14,代码来源:security.php


示例15: getInput

 public function getInput($value = '', $name = '')
 {
     $name = $name ? $name : $this->getName();
     if ($s = $this->getStatic()) {
         $r = rand(0, getrandmax());
         $s = $s . '<nobr>&nbsp;<input name="' . $name . '_delete" type="checkbox" id="' . $r . '"><label for="' . $r . '" style="position:relative; top:-2px;">удалить</label></nobr><br>';
     }
     return '<input type="hidden" name="' . $name . '_oldValue" value="' . $this->dbValue . '">' . $s . '<input type="file" name="' . $name . '" size="49" style="width:100%">';
 }
开发者ID:rawork,项目名称:colors-life,代码行数:9,代码来源:file.php


示例16: _versionHash

 protected function _versionHash()
 {
     $hash = $this->loadCache(self::FUZE_VALUE_CACHE_KEY);
     if ($hash === false) {
         $hash = sha1(rand(1, getrandmax()));
         $this->saveCache(self::FUZE_VALUE_CACHE_KEY, $hash);
     }
     return $hash;
 }
开发者ID:creatuitydevelopers,项目名称:mega-menu,代码行数:9,代码来源:Cache.php


示例17: number

 /**
  * Generate a random number/integer
  * @param int $min
  * @param int $max
  * @return int
  */
 static function number($min = 0, $max = null)
 {
     mt_srand();
     if (is_null($max)) {
         $max = getrandmax();
     }
     $number = mt_rand($min, $max);
     return $number;
 }
开发者ID:CaymanParrot,项目名称:Cayman,代码行数:15,代码来源:Random.php


示例18: upload

 /**
  * @throws FileException
  */
 public function upload()
 {
     if ($this->file instanceof File) {
         $name = sha1($this->file->getClientOriginalName() . uniqid() . getrandmax()) . '.' . $this->file->guessExtension();
         $this->file->move($this->getWeb() . $this->folder, $name);
         $this->file = $name;
     } else {
         throw new FileException('It must be a Symfony\\Component\\HttpFoundation\\File\\File instance');
     }
 }
开发者ID:radmar,项目名称:RedactorBundle,代码行数:13,代码来源:Resource.php


示例19: rand_fill

 /**
  * Fill the matrix with random values
  * To reproduce, use srand first
  * 
  * @param int $row The number of rows
  * @param int $col The number of columns
  * @param Number $min The minimum value
  * @param Number $max The maximum value
  */
 public function rand_fill($row, $col, $min = 0, $max = 1)
 {
     $maxrand = getrandmax();
     for ($i = 0; $i < $row; $i++) {
         $this->data[$i] = array();
         for ($j = 0; $j < $col; $j++) {
             $this->data[$i][$j] = rand(0, $maxrand) / $maxrand * ($max - $min) + $min;
         }
     }
 }
开发者ID:pwwang,项目名称:math.php,代码行数:19,代码来源:Matrix.php


示例20: displayValues

 public function displayValues($content_node, $transient_options, $action)
 {
     if (!($mainNode = $this->template->appendFileByNode('form_builder_menu.html', 'div', $content_node)) instanceof DOMNode) {
         I2CE::raiseError("no template form_builder_menu.html");
         return false;
     }
     if (($nameNode = $this->template->getElementByName('name', 0, $mainNode)) instanceof DOMNode) {
         $all_forms = $this->storage->getKeys();
         //these are all the classes, not just the ones with a registered handler
         $this->template->setClassValue($nameNode, 'validate_data', array('notinlist' => $all_forms), '%');
     }
     if (($storageNode = $this->template->getElementByName('storage', 0, $mainNode)) instanceof DOMNode) {
         $storeid = "class_" . rand(0, getrandmax());
         $storageNode->setAttribute('id', $storeid);
         $storages = I2CE::getConfig()->getAsArray('/modules/form-builder/storage_handlers');
         foreach ($storages as $storage => $data) {
             if (!is_array($data) || !array_key_exists('swiss', $data) || !is_scalar($swiss = $data['swiss']) || !$swiss) {
                 continue;
             }
             $attrs = array('value' => $storage);
             if (array_key_exists('description', $data)) {
                 $attrs['title'] = $data['description'];
             }
             $storageNode->appendChild($this->template->createElement('option', $attrs, $storage));
         }
     }
     if (($classNode = $this->template->getElementByName('class', 0, $mainNode)) instanceof DOMNode) {
         $classes = I2CE::getConfig()->getKeys("/modules/forms/formClasses");
         $def_storage = array();
         foreach ($classes as $class) {
             if ($class == 'I2CE_List' || is_subclass_of($class, 'I2CE_List')) {
                 $def_storage[$class] = 'magicdata';
             } else {
                 $def_storage[$class] = 'entry';
             }
             $attrs = array('value' => $class);
             $classNode->appendChild($this->template->createElement('option', $attrs, $class));
         }
         $js = 'var storages = ' . json_encode($def_storage) . '; var storage=storages[this.value];  var storageNode = $("' . $storeid . '"); if (storageNode) { storageNode.set("value",storage);}';
         $classNode->setAttribute('onChange', $js);
     }
     $this->renameInputs(array('class', 'name', 'display', 'storage'), $mainNode);
     if (($append_node = $this->template->getElementById('forms', $mainNode)) instanceof DOMNode) {
         $forms = $this->storage->getKeys();
         foreach ($forms as $form) {
             if (!($swissChild = $this->getChild($form)) instanceof I2CE_Swiss_Form || !($formNode = $this->template->appendFileByNode('form_builder_each.html', 'li', $append_node))) {
                 continue;
             }
             $this->template->setDisplayDataImmediate("form", $form, $formNode);
             $this->template->setDisplayDataImmediate("form_edit_link", $this->getURLRoot('edit') . $this->path . '/' . $form, $formNode);
             $this->template->setDisplayDataImmediate("form_delete_link", $this->getURLRoot('delete') . $this->path . '/' . $form, $formNode);
         }
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:55,代码来源:I2CE_Swiss_FormBuilder.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getrefnum函数代码示例发布时间:2022-05-15
下一篇:
PHP getqtypelist函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap