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


PHP getrandmax函数代码示例

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


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


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