<?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <refentry xml:id="mongodb-bson-javascript.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>MongoDB\BSON\Javascript::__construct</refname> <refpurpose>Construct a new Javascript</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <modifier>final</modifier> <modifier>public</modifier> <methodname>MongoDB\BSON\Javascript::__construct</methodname> <methodparam><type>string</type><parameter>code</parameter></methodparam> <methodparam choice="opt"><type>array|object</type><parameter>scope</parameter></methodparam> </methodsynopsis> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <variablelist> <varlistentry> <term><parameter>code</parameter> (<type>string</type>)</term> <listitem> <para> Javascript code. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>scope</parameter> (<type>array|object</type>)</term> <listitem> <para> Javascript scope. </para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 role="errors"> &reftitle.errors; <simplelist> &mongodb.throws.argumentparsing; <member>Throws <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> if <parameter>code</parameter> contains null bytes.</member> </simplelist> </refsect1> <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>1.2.0</entry> <entry> <para> <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> is thrown if <parameter>code</parameter> contains null bytes. Previously, values would be truncated at the first null byte. </para> </entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example> <title><function>MongoDB\BSON\Javascript::__construct</function> example</title> <programlisting role="php"> <![CDATA[ <?php $code = new MongoDB\BSON\Javascript('function() { return 1; }'); var_dump($code); $codews = new MongoDB\BSON\Javascript('function() { return foo; }', ['foo' => 'bar']); var_dump($codews); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ object(MongoDB\BSON\Javascript)#1 (2) { ["javascript"]=> string(24) "function() { return 1; }" ["scope"]=> object(stdClass)#2 (0) { } } object(MongoDB\BSON\Javascript)#2 (2) { ["javascript"]=> string(26) "function() { return foo; }" ["scope"]=> object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" } } ]]> </screen> </example> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <simplelist> <member><link xlink:href="&url.mongodb.docs.bson;">BSON Types</link></member> </simplelist> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"~/.phpdoc/manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->