Skip to content

Commit

Permalink
Merge pull request walu#132 from xuwenzhi/master
Browse files Browse the repository at this point in the history
增加面向对象(二)中关于walu_call_user_function()的说明。
  • Loading branch information
walu authored Oct 20, 2016
2 parents 7166370 + 9bdc537 commit 526e2cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 11.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ function test_call()

````
下面我们在扩展中实现以上test_call函数。

**Note:**关于下面walu_call_user_function()的说明:内核中并不存在该函数,可以在[这里](https://github.com/wosiwo/clinq/blob/41c2c32e1837a23231c3b124dd84c29d03922e97/alinq.c)找到该函数的定义,直接拷贝过来用即可。
````c
zend_class_entry *baby_ce;

Expand Down Expand Up @@ -93,6 +95,12 @@ ZEND_MINIT_FUNCTION(test)

````
重新编译,执行命令查看是否生效~
````
php -r "test_call();"
````
## links
* 11 [PHP中的面向对象(二)](<11.md>)
Expand Down
13 changes: 13 additions & 0 deletions 11.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ ZEND_METHOD(baby, __construct)

}

//为类添加age 和 area属性
PHP_MINIT_FUNCTION(say_hello)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce,"baby",myclass_method);
baby_ce = zend_register_internal_class(&ce TSRMLS_CC);

zend_declare_property_null(baby_ce, "age", strlen("age"), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(baby_ce, "area", strlen("area"), ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC);

return SUCCESS;
}

````
<div class="tip-common">
感谢 [@看你取的破名](http://weibo.com/taokuizu) 发现的错误。
Expand Down

0 comments on commit 526e2cb

Please sign in to comment.