<?php
$m = new MongoClient;
$c = $m->demo->elephpants; $c->drop();
function birthDay( $c, $name )
{
$c->update(
[ 'name' => $name ], // criteria
[ '$inc' => [ 'age' => 1 ] ], // update spec
[ 'upsert' => true ] // options
);
echo $c->findOne( [ 'name' => 'Santon' ] )['age'], "\n";
}
birthDay( $c, 'Santon' );
birthDay( $c, 'Santon' );
?>