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: MongoDB\BSON\ObjectId::__construct - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoDB\BSON\ObjectId::__construct

2025-05-14

MongoDB\BSON\ObjectId::__construct

(mongodb >=1.0.0)

MongoDB\BSON\ObjectId::__constructConstruct a new ObjectId

说明

final public MongoDB\BSON\ObjectId::__construct(?string $id = null)

参数

id (string)

A 24-character hexadecimal string. If not provided, the extension will generate an ObjectId.

错误/异常

示例

示例 #1 MongoDB\BSON\ObjectId::__construct() example

<?php

var_dump
(new MongoDB\BSON\ObjectId());

var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));

?>

以上示例的输出类似于:

object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "56732d3dda14d81214634921"
}
object(MongoDB\BSON\ObjectId)#1 (1) {
  ["oid"]=>
  string(24) "000000000000000000000001"
}
添加备注

用户贡献的备注 1 note

up
4
fejlesztes at letscode dot hu
9 years ago
If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.

官方地址:https://www.php.net/manual/en/mongodb-bson-objectid.construct.php

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