
MongoDBBSONDocument::toPHP 함수는 MongoDB의 BSON 문서를 PHP 객체로 변환하는 데 사용됩니다. 이 함수는 PHP의 stdClass 객체로 변환합니다.
예를 들어, MongoDB의 BSON 문서가 다음과 같이 있다고 가정해 보겠습니다.
#hostingforum.kr
php
$document = new MongoDBBSONUTCDateTime('2022-01-01T00:00:00.000Z');
$document->name = 'John Doe';
$document->age = 30;
이 BSON 문서를 PHP 객체로 변환하려면 toPHP 함수를 사용하세요.
#hostingforum.kr
php
$phpObject = $document->toPHP();
print_r($phpObject);
이 코드를 실행하면 stdClass 객체가 출력됩니다.
#hostingforum.kr
php
stdClass Object
(
[name] => John Doe
[age] => 30
)
이 stdClass 객체는 PHP의 기본 객체 타입으로, PHP 개발자들은 쉽게 사용할 수 있습니다.
이러한 stdClass 객체를 사용하여 데이터를 처리하거나 저장할 수 있습니다.
2025-04-06 10:34