欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php7擴(kuò)展類怎么實(shí)現(xiàn)

小編給大家分享一下php7擴(kuò)展類怎么實(shí)現(xiàn),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),甘州網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:甘州等地區(qū)。甘州做網(wǎng)站價(jià)格咨詢:18982081108

在php7中,有許許多多的擴(kuò)展類,今天我們就以person類為例實(shí)現(xiàn)doing方法和saying方法,有需要的小伙伴可以參考一下。

1.需要實(shí)現(xiàn)的細(xì)節(jié)

實(shí)現(xiàn)一個(gè)person類

實(shí)現(xiàn)一個(gè)doing方法和saying方法

2.第一個(gè)擴(kuò)展

2.1創(chuàng)建類的擴(kuò)展:

[root@bogon ext]# cd /usr/local/src/php-7.0.3/ext
[root@bogon ext]# ./ext_skel --extname=person

2.2 修改配置

[root@bogon ext]# vim person/config.m4
dnl PHPARGWITH(person, for person support,
dnl Make sure that the comment is aligned:
dnl [ --with-person Include person support])

更改為:

PHPARGWITH(person, for person support,
dnl Make sure that the comment is aligned:
[ --with-person Include person support])

2.3 實(shí)現(xiàn)代碼

在php_person.h頭中加上

extern zend_class_entry *person_ce;
PHP_METHOD(person_ce,__construct);
PHP_METHOD(person_ce,saying);
PHP_METHOD(person_ce,doing);

在person.c頭中加上

/** * 聲明構(gòu)造函數(shù) * 
@param * @return */
ZEND_METHOD(person,__construct){        
zval *pThis;        
pThis = getThis();    
zend_printf("construct\n");
}
/** * 聲明析造函數(shù) *
 @param * @return */
ZEND_METHOD(person,__destruct){    
zend_printf("destruct\n");
}
ZEND_METHOD(person,doing){    
zend_printf("doing\n");
}
ZEND_METHOD(person,saying){    
zend_printf("saying\n");
}
//這個(gè)函數(shù)需要加上聲明,去掉了沒用的test函數(shù)const zend_function_entry person_functions[] = {    
ZEND_ME(person, __construct, global_config_arg, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)    
ZEND_ME(person,doing,NULL,ZEND_ACC_PUBLIC) ZEND_ME(person,saying,NULL,ZEND_ACC_PUBLIC)    
ZEND_ME(person,__destruct,NULL,ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)    
PHP_FE_END  
/* Must be the last line in person_functions[] */
};
//將類和方法注冊(cè)到zendPHP_MINIT_FUNCTION(person){       
zend_class_entry ce;       
INIT_CLASS_ENTRY(ce, "person", person_functions);       
person_ce = zend_register_internal_class(&ce TSRMLS_CC);       
zend_declare_property_null(person_ce,"saying",strlen("saying"),ZEND_ACC_PUBLIC);       
zend_declare_property_null(person_ce,"doing",strlen("doing"),ZEND_ACC_PUBLIC);    
return SUCCESS;
}

2.4 編譯

* [root@bogon hello]# [root@localhost person]# ./configure && make && make install

2.5 擴(kuò)展安裝

改更php.ini 加上

[person] extenstion=person.so

2.6 擴(kuò)展使用

[root@bogon tests]# cat test.php
<?php
$n = new person();
echo $n->saying();
echo $n->doing();
[root@localhost tests]# php test.phpconstructsayingdoingdestruct

以上是“php7擴(kuò)展類怎么實(shí)現(xiàn)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

本文標(biāo)題:php7擴(kuò)展類怎么實(shí)現(xiàn)
網(wǎng)頁地址:http://chinadenli.net/article2/geosoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站網(wǎng)站導(dǎo)航搜索引擎優(yōu)化軟件開發(fā)網(wǎng)站建設(shè)網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)