Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<MongoDB\BSON\Javascript::jsonSerializeMongoDB\BSON\MaxKey>
^MongoDB\BSON\JavascriptLast updated: Mon, 26 Oct 2026

MongoDB\BSON\Javascript::__toString

(mongodb >=1.2.0)

MongoDB\BSON\Javascript::__toString — Returns the Javascript's code

Description

final public function MongoDB\BSON\Javascript::__toString(): string

This method is an alias of: MongoDB\BSON\Javascript::getCode().

Parameters

This function has no parameters.

Return Values

Returns the Javascript's code.

Examples

Example #1 MongoDB\BSON\Javascript::__toString() example

<?php

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

?>

The above example will output:

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

See Also


<MongoDB\BSON\Javascript::jsonSerializeMongoDB\BSON\MaxKey>
^MongoDB\BSON\JavascriptLast updated: Mon, 26 Oct 2026