Closed dofounds closed 11 years ago
Hi, parseFromString
is static method. so we should use it like this.
<?php
require "php/addressbook.proto.php";
$db = "addressbook.db";
$handle = fopen($db, "r");
// $data is raw protocol buffers binary data.
$data = fread($handle, filesize ($db));
// you can decode it with `ProtocolBuffers::decode("Tutorial_AddressBook", $data);`
$addressbook = ProtocolBuffers::decode("Tutorial_AddressBook", $data);
// or you can use $addressbook = Tutorial_AddressBook::parseFromString($data);
foreach ($addressbook->getPerson() as $person) {
var_dump($person);
}
Thanks,
Thank you very much.
so: <?php require "addressbook.proto.php"; $db = "addressbook.db"; $handle = fopen($db, "r"); $data = fread($handle, filesize ($db)); $person = new Tutorial_AddressBook (); $data = $person->parseFromString($data);
//$tm = $person->getDescriptor();
//echo $tm->getName(); print_r($data);
exit;
how to get the "$data" information. and use the class functions