php8.5
Home/ Manual/ bson / javascript/ MongoDB\BSON\Javascript::__toString

MongoDB\BSON\Javascript::__toString

PHP function Edit on GitHub ✎

(mongodb >=1.2.0)

Returns the Javascript's code

Description

MongoDB\BSON\Javascript::__toString(): string

Alias MongoDB\BSON\Javascript::getCode.

Parameters Parameters

Return Values

Returns the Javascript's code.

Examples

MongoDB\BSON\Javascript::__toString() example

php
<?php

var_dump((string) new MongoDB\BSON\Javascript('function foo(bar) { return bar; }'));

?>

The above example will output:

output
string(33) "function foo(bar) { return bar; }"

See Also

  • MongoDB\BSON\Javascript::getCode
  • BSON Types

Source: reference/mongodb/bson/javascript/tostring.xml · from the official PHP manual (php/doc-en)