Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pangudashu committed May 24, 2017
1 parent fdc34c3 commit 2bd01a1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 3/zend_class.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,19 @@ struct _zend_class_entry {
} info;
}
```
> create_object为实例化对象的操作,可以通过扩展自定义这个函数
create_object为实例化对象的操作,可以通过扩展自定义一个函数来接管实例化对象的操作,没有定义这个函数的话将由默认的`zend_objects_new()`处理,自定义时可以参考这个函数的实现:
```c
//注意:此操作并没有将属性拷贝到zend_object中:由object_properties_init()完成
ZEND_API zend_object *zend_objects_new(zend_class_entry *ce)
{
zend_object *object = emalloc(sizeof(zend_object) + zend_object_properties_size(ce));

zend_object_std_init(object, ce);
//设置对象操作的handler
object->handlers = &std_object_handlers;
return object;
}
```
举个例子具体看下,定义一个User类,它继承了Human类,User类中有一个常量、一个静态属性、两个普通属性:
```php
//父类
Expand Down

0 comments on commit 2bd01a1

Please sign in to comment.