Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: Random\Randomizer::getBytes - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Random\Randomizer::getBytes

2025-05-18

Random\Randomizer::getBytes

(PHP 8 >= 8.2.0)

Random\Randomizer::getBytesGet random bytes

说明

public Random\Randomizer::getBytes(int $length): string

Generates a string containing uniformly selected random bytes with the requested length.

As the returned bytes are selected completely randomly, the resulting string is likely to contain unprintable characters or invalid UTF-8 sequences. It may be necessary to encode it before transmission or display.

参数

length

The length of the random string that should be returned in bytes; must be 1 or greater.

返回值

A string containing the requested number of random bytes.

错误/异常

示例

示例 #1 Random\Randomizer::getBytes() example

<?php
$r
= new \Random\Randomizer();

echo
bin2hex($r->getBytes(8)), "\n";
?>

以上示例的输出类似于:

ebdbe93cd56682c2

参见

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。

官方地址:https://www.php.net/manual/en/random-randomizer.getbytes.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3