PHP 7.4.0RC6 Released!

MongoId::__toString

(PECL mongo >= 0.8.0)

MongoId::__toStringReturns a hexidecimal representation of this id

Descrição

public MongoId::__toString ( void ) : string

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

This id.

Exemplos

Exemplo #1 MongoId::__toString() example

<?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";

?>

O exemplo acima irá imprimir algo similar à:

49a7011a05c677b9a916612a
49a702d5450046d3d515d10d
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top