本文整理匯總了PHP中Inflector::random方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::random方法的具體用法?PHP Inflector::random怎麽用?PHP Inflector::random使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::random方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: make
/**
* Hash a password using the Bcrypt hashing scheme.
*
* <code>
* // Create a Bcrypt hash of a value
* $hash = Hash::make('secret');
*
* // Use a specified number of iterations when creating the hash
* $hash = Hash::make('secret', 12);
* </code>
*
* @param string $value
* @param int $rounds
* @return string
*/
public static function make($value, $rounds = 8)
{
$work = str_pad($rounds, 2, '0', STR_PAD_LEFT);
// Bcrypt expects the salt to be 22 base64 encoded characters including
// dots and slashes. We will get rid of the plus signs included in the
// base64 data and replace them with dots.
if (function_exists('openssl_random_pseudo_bytes')) {
$salt = openssl_random_pseudo_bytes(16);
} else {
$salt = Inflector::random(40);
}
$salt = substr(strtr(base64_encode($salt), '+', '.'), 0, 22);
return crypt($value, '$2a$' . $work . '$' . $salt);
}
示例2: getVoucherCode
public function getVoucherCode()
{
return Inflector::upper(Inflector::random(9));
}
示例3: imagecreatetruecolor
<?php
namespace Thin;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'init.php';
require_once APPLICATION_PATH . DS . 'Bootstrap.php';
Bootstrap::cli();
$text = Inflector::random(9);
session()->setCaptcha($text);
$height = 25;
$width = 120;
$font_size = 14;
$im = imagecreatetruecolor($width, $height);
$textcolor = imagecolorallocate($im, 80, 80, 80);
$bg = imagecolorallocate($im, 0, 0, 0);
imagestring($im, $font_size, 5, 5, $text, $textcolor);
imagecolortransparent($im, $bg);
imagefill($im, 0, 0, $bg);
imagepng($im, null, 9);
imagedestroy($im);
示例4: makeVoucher
public function makeVoucher()
{
return 'R' . Inflector::upper(Inflector::random(9));
}