MongoCode
PHP Manual

MongoCode::__construct

(PECL mongo >= 0.8.3)

MongoCode::__constructCreates a new code object

Description

MongoCode::__construct ( string $code [, array $scope= array() ] )

Parameters

code

A string of code.

scope

The scope to use for the code.

Return Values

Returns a new code object.

Examples

Example #1 MongoCode::__construct() example

<?php

$code 
= new MongoCode('function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }', array("x" => 4));
var_dump($code);

?>

The above example will output something similar to:

object(MongoCode)#1 (2) {
  ["scope"]=>
  array(1) {
    ["x"]=>
    int(4)
  }
  ["code"]=>
  string(80) "function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }"
}

MongoCode
PHP Manual