array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.mongodb.bson-fromphp.php', 1 => 'MongoDB\\BSON\\fromPHP', 2 => 'Returns the BSON representation of a PHP value', ), 'up' => array ( 0 => 'ref.bson.functions.php', 1 => 'Функції', ), 'prev' => array ( 0 => 'function.mongodb.bson-fromjson.php', 1 => 'MongoDB\\BSON\\fromJSON', ), 'next' => array ( 0 => 'function.mongodb.bson-tocanonicalextendedjson.php', 1 => 'MongoDB\\BSON\\toCanonicalExtendedJSON', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mongodb/functions/bson/fromphp.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

MongoDB\BSON\fromPHP

(mongodb >=1.0.0)

MongoDB\BSON\fromPHPReturns the BSON representation of a PHP value

Увага

This function has been DEPRECATED as of extension version 1.20.0 and was removed in 2.0. Applications should use MongoDB\BSON\Document::fromPHP() instead.

Опис

MongoDB\BSON\fromPHP(array|object $value): string

Serializes a PHP array or object (e.g. document) to its » BSON representation. The returned binary string will describe a BSON document.

Параметри

value (array|object)

PHP value to be serialized.

Значення, що повертаються

The serialized BSON document as a binary string.

Помилки/виключення

Журнал змін

Версія Опис
PECL mongodb 2.0.0 This function was removed.

Приклади

Приклад #1 MongoDB\BSON\fromPHP() example

<?php

$bson
= MongoDB\BSON\fromPHP(['foo' => 1]);
echo
bin2hex($bson), "\n";

?>

Поданий вище приклад виведе:

0e00000010666f6f000100000000cat

Прогляньте також