1、PHP扩展开发,更多内容 请见2015-04-14 下午分享会,NTS or TS,None Thread Safe(非线程安全) Thread Safe(线程安全),开发环境,Windows OR Linux X86 OR X64,Windows环境,VC6(Microsoft Visual C+ 6.0) VC9( Microsoft Visual Studio 2008) VC11( Microsoft Visual Studio 2012)Cygwin64 OR Cygwin_X86 Php-deps php-sdk-binary-tools Php源码,Windows开发流程,Bui
2、ldconf configure ext_skel_win32.php 参数-extname 扩展名称-proto 定义文件 编译,Linux开发流程,ext_skel-extname 扩展名称-proto 定义文件 config.m4,PHP_ARG_WITH(example, for example support, -with-example=FILE Include example support. File is the optional path to example-config)PHP_ARG_WITH(example-extra, for extra libraries fo
3、r example, -with-example-extra=DIR example: Location of extra libraries for example, no, no),Linux开发流程,Phpize configure -with-php-config=/usr/local/php/bin/php-config Make Make install,PHP的变量,typedef struct _zval_struct zvalue_value value;zend_uint refcount;zend_uchar type;zend_uchar is_ref; zval;,t
4、ypedef union _zvalue_value long lval;double dval;struct char *val;int len; str;HashTable *ht;zend_object_value obj; zvalue_value;,typedef struct _zval_struct zval;,获取参数,zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, );,返回值,自定义php函数,?php$i=3;echo self_concat(“Hello World“, $i);,Eg.1,P
5、HP_FUNCTION(self_concat) char *str = NULL; int argc = ZEND_NUM_ARGS(); int str_len; long n; char *result; char *ptr; int result_length; if (zend_parse_parameters(argc TSRMLS_CC, “sl“, ,Eg.2,result_length = (str_len * n); result = (char *) emalloc(result_length + 1); ptr = result; while (n-) memcpy(ptr, str, str_len); ptr += str_len; *ptr = /0;,Eg.3,RETURN_STRINGL(result, result_length, 0); ,谢谢大家,