略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoId::__toString

2024-05-02

MongoId::__toString

(PECL mongo >= 0.8.0)

MongoId::__toString返回该 id 十六进制的表示形式

说明

public MongoId::__toString ( void ) : string

参数

此函数没有参数。

返回值

该 id。

范例

Example #1 MongoId::__toString() 例子

<?php

$m 
= new MongoClient();
$collection $m->selectDB("foo")->selectCollection("bar");

$collection->insert(array( "x" => "y" ));
$collection->insert(array( "x" => "y" ));

$cursor $collection->find();
$r1 $cursor->next();
$r2 $cursor->next();

echo 
$r1["_id"] . "\n";
echo 
$r2["_id"] . "\n";

?>

以上例程的输出类似于:

49a7011a05c677b9a916612a
49a702d5450046d3d515d10d
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/mongoid.tostring.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3