由于项目中正在使用protocolbuffers,整个项目中使用到的扩展基本都已经支持php7,只有protocolbuffers这个还不支持php7,原作者已经停止维护了该扩展,无奈只能自己开始研究如何将protocolbuffers扩展的5.x版本升级到php7。目前该扩展可以通过编译。github
<code>Number of tests : 144 144 Tests skipped : 0 ( 0.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 67 ( 46.5%) ( 46.5%) Expected fail : 0 ( 0.0%) ( 0.0%) Tests passed : 77 ( 53.5%) ( 53.5%)</code>
以下为测试代码:
beta v1.1版本为第一个版本,简单的整合了基础功能,各位站长拿到程序后,不要纠结后台的功能简单,后续将不断更新扩展。在beta v1.1版本使用过程中遇到什么问题,请登录 www.loftto.com 进行反馈! 安装说明######重要提醒:程序不支持二级目录安装,请使用一级目录或二级目录绑定!#第一步,确定你的服务器支持PHP+mysql。#第二步,确定你的服务器开启了gd库。#第三步,
0
<code><?php
require dirname(__FILE__) . DIRECTORY_SEPARATOR . "messages" . DIRECTORY_SEPARATOR . "field_int32.proto.php";
$bytes = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . "fixtures" . DIRECTORY_SEPARATOR . "001_int32_init.bin");
$u = new Tutorial_Integer32();
$u->setValue(0);
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
var_dump($obj);
if ($obj instanceof Tutorial_Integer32) {
var_dump($obj->getValue());
if ($obj->getValue() == 0) {
echo "OK" . PHP_EOL;
} else {
var_dump($obj);
}
} else {
var_dump($obj);
}
ini_set("protocolbuffers.native_scalars", 1);
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
if ($obj instanceof Tutorial_Integer32) {
var_dump($obj->getValue());
if ($obj->getValue() === 0) {
echo "OK" . PHP_EOL;
} else {
var_dump($obj);
}
} else {
var_dump($obj);
}
</code>输出结果如下:
立即学习“PHP免费学习笔记(深入)”;
<code>object(Tutorial_Integer32)#2 (2) {
["_properties":protected]=>
array(0) {
}
["value":protected]=>
string(1) "0"
}
NULL
OK
NULL
object(Tutorial_Integer32)#3 (2) {
["_properties":protected]=>
array(0) {
}
["value":protected]=>
int(0)
}</code>问题总结:在protocolbuffers::decode时,能够返回被解析的对象,但是对象的属性无法读取。求解中。。。
由于项目中正在使用protocolbuffers,整个项目中使用到的扩展基本都已经支持php7,只有protocolbuffers这个还不支持php7,原作者已经停止维护了该扩展,无奈只能自己开始研究如何将protocolbuffers扩展的5.x版本升级到php7。目前该扩展可以通过编译。github
<code>Number of tests : 144 144 Tests skipped : 0 ( 0.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 67 ( 46.5%) ( 46.5%) Expected fail : 0 ( 0.0%) ( 0.0%) Tests passed : 77 ( 53.5%) ( 53.5%)</code>
以下为测试代码:
<code><?php
require dirname(__FILE__) . DIRECTORY_SEPARATOR . "messages" . DIRECTORY_SEPARATOR . "field_int32.proto.php";
$bytes = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . "fixtures" . DIRECTORY_SEPARATOR . "001_int32_init.bin");
$u = new Tutorial_Integer32();
$u->setValue(0);
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
var_dump($obj);
if ($obj instanceof Tutorial_Integer32) {
var_dump($obj->getValue());
if ($obj->getValue() == 0) {
echo "OK" . PHP_EOL;
} else {
var_dump($obj);
}
} else {
var_dump($obj);
}
ini_set("protocolbuffers.native_scalars", 1);
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
if ($obj instanceof Tutorial_Integer32) {
var_dump($obj->getValue());
if ($obj->getValue() === 0) {
echo "OK" . PHP_EOL;
} else {
var_dump($obj);
}
} else {
var_dump($obj);
}
</code>输出结果如下:
立即学习“PHP免费学习笔记(深入)”;
<code>object(Tutorial_Integer32)#2 (2) {
["_properties":protected]=>
array(0) {
}
["value":protected]=>
string(1) "0"
}
NULL
OK
NULL
object(Tutorial_Integer32)#3 (2) {
["_properties":protected]=>
array(0) {
}
["value":protected]=>
int(0)
}</code>问题总结:在protocolbuffers::decode时,能够返回被解析的对象,但是对象的属性无法读取。求解中。。。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号