MongoId::__construct

(PECL mongo >= 0.8.0)

MongoId::__construct锟斤拷锟斤拷一锟斤拷锟铰碉拷id

说锟斤拷

public MongoId::__construct ([ string|MongoId $id = NULL ] )

锟斤拷锟斤拷

id

锟斤拷锟斤拷 id 锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷为24锟斤拷十锟斤拷锟斤拷锟狡碉拷锟街凤拷锟斤拷锟斤拷锟斤拷也锟斤拷锟斤拷锟斤拷 MongoId 实锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷一锟斤拷锟铰碉拷 id锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
1.4.0 锟斤拷锟斤拷锟斤拷效锟街凤拷锟斤拷锟阶筹拷锟届常

锟斤拷锟斤拷

Example #1 MongoId::__construct() 锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷锟秸故撅拷锟斤拷锟轿达拷锟斤拷一锟斤拷锟铰碉拷 id锟斤拷 锟斤拷锟斤拷锟斤拷玫锟斤拷锟斤拷锟轿拷诒锟斤拷娴斤拷锟斤拷菘锟街帮拷锟斤拷锟斤拷锟斤拷锟轿拷锟斤拷锟斤拷远锟斤拷锟斤拷一锟斤拷id锟斤拷

<?php

  $id1 
= new MongoId();
  echo 
"$id1\n";

  
$id2 = new MongoId();
  echo 
"$id2\n";

  
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

49a7011a05c677b9a916612a
49a702d5450046d3d515d10d

Example #2 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷锟秸故撅拷锟斤拷锟斤拷使锟斤拷 string 锟侥诧拷锟斤拷锟斤拷锟斤拷始锟斤拷一锟斤拷指锟斤拷值锟斤拷 MongoId锟斤拷

<?php
  $id1 
= new MongoId();

  
// 锟斤拷 $id1 锟斤拷锟斤拷一锟斤拷锟铰碉拷 MongoId
  
$id2 = new MongoId("$id1");

  
// 锟斤拷示 $id1 锟斤拷 $id2 锟斤拷锟斤拷锟斤拷同锟斤拷十锟斤拷锟斤拷锟斤拷值
  
var_dump($id1 == $id2);
  
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

bool(true)

锟轿硷拷