Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

交流&吐槽 #3

Open
pangudashu opened this issue Mar 24, 2017 · 26 comments
Open

交流&吐槽 #3

pangudashu opened this issue Mar 24, 2017 · 26 comments

Comments

@pangudashu
Copy link
Owner

@pangudashu pangudashu commented Mar 24, 2017

No description provided.

@pangudashu pangudashu changed the title 交流&扯淡 交流&吐槽 Mar 29, 2017
@whiteHat001

This comment has been minimized.

Copy link

@whiteHat001 whiteHat001 commented May 16, 2017

这样看太抽象了,给些实际的gdb调试例子会好些

@pangudashu

This comment has been minimized.

Copy link
Owner Author

@pangudashu pangudashu commented May 17, 2017

好的,后续会补充些 @whiteHat001

@hihozhou

This comment has been minimized.

Copy link

@hihozhou hihozhou commented May 23, 2017

@pangudashu ,我最近在用C++写一个php扩展项目,我想要php扩展中的对象中的属性可以绑定到C++的对象属性,使得php中调用_get_set的时候可以同事修改C++对象的属性。
zend_update_property()可以更新PHP的对象属性,但是没有成功绑定C++的对象属性。
例如:

//PHP extension code:
PHP_METHOD(Car, __construct)
{
    Car *car = NULL;
    zval *object = getThis();
    car = new Car();
    car_object *obj = Z_PHP7OBJ_P(object);
    obj->car = car;
    zend_update_property_long(car_ce, getThis(), "speed", sizeof("speed")-1, obj->car->speed TSRMLS_CC);
}

PHP_METHOD(Car, accelerate)
{
    Car *car;
    car_object *obj =Z_PHP7OBJ_P(getThis());
    car = obj->car;
    if (car != NULL) {
        car->accelerate();
    }
}

PHP_METHOD(Car, getCurrentSpeed)
{
    Car *car;
    car_object *obj = Z_PHP7OBJ_P(getThis());
    car = obj->car;
    if (car != NULL) {
        RETURN_LONG(car->getCurrentSpeed());
    }
    RETURN_NULL();
}
//c++ code:
#include "car.h"

Car::Car() {
    this->speed = 0;
}


void Car::accelerate() {
    this->speed += 5;
}

int Car::getCurrentSpeed() {
    return this->speed;
}
//php code:
$car = new Car();
echo $car->speed;//echo 0
echo $car->getCurrentSpeed();// echo 0
$car->accelerate();
echo $car->speed;//echo 0,但是我想要的是5
echo $car->getCurrentSpeed();// echo 5

我在想,是不是php扩展中有提供宏可以实现,又或者在扩展中重写_get和_set的魔术方法,但是都不知道怎样去实现

@pangudashu pangudashu closed this May 24, 2017
@pangudashu pangudashu reopened this May 24, 2017
@imaben

This comment has been minimized.

Copy link
Contributor

@imaben imaben commented May 26, 2017

@pangudashu 建议建个QQ或微信群讨论起来更加方便

@hihozhou

This comment has been minimized.

Copy link

@hihozhou hihozhou commented May 27, 2017

@imaben @pangudashu 我也这么认为,让大家可以讨论讨论分享经验,我也可以帮人解答我知道的问题

@yanwenwu

This comment has been minimized.

Copy link

@yanwenwu yanwenwu commented Jun 2, 2017

可以开个交流群吗?

@LHRchina

This comment has been minimized.

Copy link

@LHRchina LHRchina commented Jun 6, 2017

感谢pangudashu的精心制作,会坚持读下去的

@toxmc

This comment has been minimized.

Copy link
Contributor

@toxmc toxmc commented Jun 8, 2017

readme中的交流群是微信的,怎么不用qq

@zimuyang

This comment has been minimized.

Copy link
Contributor

@zimuyang zimuyang commented Jun 12, 2017

赞!

1 similar comment
@secretgao

This comment has been minimized.

Copy link

@secretgao secretgao commented Jun 23, 2017

赞!

@yunyu2019

This comment has been minimized.

Copy link

@yunyu2019 yunyu2019 commented Jun 28, 2017

有的底层c代码段建议标注上文件出处,因为某些部分讲解代码跳跃性太大,需要全文件夹搜索代码出处

@CraryPrimitiveMan

This comment has been minimized.

Copy link

@CraryPrimitiveMan CraryPrimitiveMan commented Oct 8, 2017

是不是可以考虑忽略具体实现的代码,写成大家易于理解的代码,效果会好一些。就像《Redis设计与实现》中,大部分代码都是作者用python简写的,便于大家理解。

@pangudashu

This comment has been minimized.

Copy link
Owner Author

@pangudashu pangudashu commented Oct 9, 2017

@CraryPrimitiveMan 有些部分确实罗列了太多的源码不太容易理解,后面会优化删除非关键的实现,保留最核心的部分。这个项目最初的定位是作为PHP内核的开发手册,而不是一本科普性质的书,所以会尽可能全、细的介绍,希望让更多的人可以具备PHP内核的开发能力,而不仅仅是了解。

@medmin

This comment has been minimized.

Copy link

@medmin medmin commented Nov 1, 2017

能搞一个gitbook之类的么,可以在线看,或者转化为pdf

@yunyu2019

This comment has been minimized.

Copy link

@yunyu2019 yunyu2019 commented Nov 1, 2017

@medmin 现在的文档是markdown的格式,可以git clone下来,转换成html,自己本机部署成web项目进行查看

@whiteHat001

This comment has been minimized.

Copy link

@whiteHat001 whiteHat001 commented Nov 23, 2017

再回来看发现作者都要出书了啊,恭喜大佬了

@xcl3721

This comment has been minimized.

Copy link

@xcl3721 xcl3721 commented Nov 24, 2017

盘古大叔,可否增加gdb调试发现php故障章节,如服务卡死,如何使用pstack strace gdb php7/.initgdb等信息

@yunyu2019

This comment has been minimized.

Copy link

@yunyu2019 yunyu2019 commented Dec 7, 2017

第三章opcache有两节内容什么时候放出来呢

@tanhaipeng

This comment has been minimized.

Copy link

@tanhaipeng tanhaipeng commented Dec 21, 2017

能搞一个gitbook之类的么,可以在线看,或者转化为pdf

@Littlesqx

This comment has been minimized.

Copy link

@Littlesqx Littlesqx commented Aug 5, 2018

环境 php 7.2 ,有没有同学告知下为何是 2 3 4

<?php
$a = [];
xdebug_debug_zval('a'); // refcount=2
$b = $a;
xdebug_debug_zval('a'); // refcount=3
$c = $a;
xdebug_debug_zval('a'); // refcount=4

另外,作者这本书有错误的地方,引用计数部分沿用了 php 5 的,其实 php 7 有改动:

前面已经介绍过PHP变量的内存管理,即引用计数机制,当变量赋值、传递时并不会直接硬拷贝,而是增加value的引用数,unset、return等释放变量时再减掉引用数

php 7 中基本类型不会增加引用数。鸟哥这篇文章才是正确的:深入理解PHP7内核之 Reference

@pangudashu

This comment has been minimized.

Copy link
Owner Author

@pangudashu pangudashu commented Aug 6, 2018

@Littlesqx 引用计数是在第2章介绍的,第5章的主题不是引用计数,你贴的那段在那里只是泛指好吗。另外你贴的鸟哥这篇文章是关于“引用(reference)”的,而不是“引用计数(refcount)”

@Littlesqx

This comment has been minimized.

Copy link

@Littlesqx Littlesqx commented Aug 6, 2018

@pangudashu 嗯,我仔细看了下,是我的问题,抱歉。

最简单的类型是 true、false、long、double、null,其中true、false、null 没有 value,
直接根据 type 区分,而long、double 的值则直接存在 value 中:zend_long、double,
也就是标量类型不需要额外的value指针。

这里已经说的很清楚了。

@flymenn

This comment has been minimized.

Copy link

@flymenn flymenn commented Aug 15, 2018

大佬写的非常精辟。但是能不能给文件加上目录号码。。这样查的时候也方便。。

@pakoneko

This comment has been minimized.

Copy link

@pakoneko pakoneko commented Apr 26, 2019

一个腾讯课堂上在线收费培训机构分发的公开课教材是这本书的内容,大叔应该跟这家没关系吧?😮感觉他们的讲师水平写不了这个

@wistonehorse

This comment has been minimized.

Copy link

@wistonehorse wistonehorse commented Jun 24, 2019

大叔,写这个的时候是以php7.几为基础写的?

@pangudashu

This comment has been minimized.

Copy link
Owner Author

@pangudashu pangudashu commented Jun 26, 2019

@wistonehorse 7.0.28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.