Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[PHP] User Defined Extension

Ϊ PHP Ìí¼ÓÀ©Õ¹¿âÊÇÒ»¼þ¼òµ¥µÄÊÂÇé¡£²»¹ýÊ×ÏÈÄã×îºÃ»áÒ»µãµãC/C++±à³Ì¼¼Êõ£¬²¢ÇÒ¶ÔMakefileÓÐÒ»¶¨µÄÁ˽⡣
ÒÔÏÂÊÇÔÚ Linux ϵÄÒ»¸ö¼òµ¥Àý×Ó£º
Ê×ÏÈ£¬½øÈë php Ô´´úÂëĿ¼£¨¼ÙÉèΪ PHP_SRC£¬ÒÔÏÂͬ£©£¬Ê¹Óà php ×Ô´øµÄ ext_skel ¹¤¾ßÉú³ÉÒ»¸öÐÂÀ©Õ¹ mk4php£º
cd PHP_SRC/etc;
./ext_skel --extname=mk4php
Õý³£Çé¿öÏÂÄú»á¿´µ½ÀàËÆÕâÑùµÄÊä³ö£º
Creating directory mk4php
Creating basic files: config.m4 config.w32 .cvsignore mk4php.c php_mk4php.h CREDITS EXPERIMENTAL tests/001.phpt mk4php.php [done].
To use your new extension, you will have to execute the following steps:
1.  $ cd ..
2.  $ vi ext/mk4php/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-mk4php
5.  $ make
6.  $ ./php -f ext/mk4php/mk4php.php
7.  $ vi ext/mk4php/mk4php.c
8.  $ make
Repeat steps 3-6 until you are satisfied with ext/mk4php/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.
 
´Ëʱ»áÔÚ ext/ Ŀ¼ÏÂÉú³ÉÒ»¸öÒÔ mk4php ÃüÃûµÄĿ¼£¬½øÈ¥¿´¿´¡£
±à¼­ ext/mk4php/ Ŀ¼ÏÂÃæµÄ config.m4 Îļþ£¬ÕÒµ½ÏÂÃæÈýÐУ¬É¾µôÇ°ÃæµÄ dnl ǰ׺£º
dnl PHP_ARG_WITH(mk4php, for mk4php support,
dnl Make sure that the comment is aligned:
dnl [  --with-mk4php             Include mk4php support])
˵Ã÷£º
1. dnl ÊÇ×¢ÊÍ£¬É¾µô±íʾʹ¸ÄÐÐÉúЧ£¬·ñÔò make µÄʱºò²»»áÉú³ÉÏàÓ¦µÄ modules
2. Ò²¿ÉÒÔʹÓÃÏÂÃæ°¤×ŵĹØÓÚ --enable-mk4php ÄÇÈýÐУ¬Á½ÕßµÄÇø±ðÔÚÓÚÄãµÄÀ©Õ¹ÊÇ·ñÐèÒªÒýÓÃÍⲿµÄ¿â
È»ºó¾ÍÊÇ configure; make; make install
configure µÄʱºò£¬Èç¹ûÄãµÄ apxs ºÍ php-config ²»ÔÚĬÈÏ·¾¶ÉÏ£¬ÔòÐèÒªÖ¸¶¨ËüÃÇ
./configure --with-mk4php --with-apxs=/usr/local/apache/bin/apxs --with-php-config=/usr/local/php/bin/php-config
make
make install
˵Ã÷£º
1. make ³É¹¦Ö®ºó»áÔÚ ext/mk4php/modules/ ÏÂÉú³ÉÏàÓ¦µÄ .so Îļþ
2. make install ¾ÍÊÇ°Ñ modules/* ¸´ÖƵ½ php µÄ extensions Ŀ¼
ÔÙÏÂÀ´¾ÍÊÇÔÚ php.ini ÀïÌí¼ÓÒ»ÐУº
extension=mk4php.so
×îºó¼ì²éÒ»ÏÂÊÇ·ñ°²×°


Ïà¹ØÎĵµ£º

phpѧϰ±Ê¼Ç£¨12£©:PHP+MYSQLÁôÑ԰壨ÉÏ

require()  Óë  require_once()
    
      ͨ³£·ÅÔÚ PHP ³ÌÐòµÄ×îÇ°Ã棬PHP ³ÌÐòÔÚÖ´ÐÐÇ°£¬¾Í»áÏȶÁÈë require
ËùÖ¸¶¨ÒýÈëµÄÎļþ£¬Èç¹û³öÏÖ´íÎóÊÇÖÂÃüµÄ¡£
nclude()  Óë  include_once()
    
    &n ......

PHP¹¤³Ìʦ±ÊÊÔÌâ

 Ò»¸ö¹«Ë¾¼òµ¥µÄÃæÊÔÌ⣺
1. ¼ò´ðÌâ
(1)һЩÏà¹ØLINUX·½ÃæµÄÖ¸Áî²Ù×÷eg: mkdir ´´½¨Ä¿Â¼ touch ´´½¨Îļþ¼ÐÒÔ¼°ÐÞ¸ÄȨÏÞchmodÖ®ÀàµÈµÈ
(2)¼òÊö²»Í¬°æ±¾µÄPHPÓÐʲôÇø±ð,ÊÔ¾ÙÀý¼òÊö.
(3),¼òÊö½Ó¿Ú¼¼ÊõµÄºÃ´¦,ÊÔ¾ÙÀý¼òÊö.
(4)ÈçºÎʹÓÃÏÂÃæµÄÀà,²¢½âÊÍÏÂÃæʲôÒâ˼?
class test{
    function ......

PHP»ù±¾·ûºÅ¼°·½·¨

×¢½â·ûºÅ:
         // µ¥ÐÐ×¢½â    
         /*      */    ¶àÐÐ×¢½â
ÒýºÅµÄʹÓÃ
         ’   ’ µ ......

PHPµÚÒ»ÕÂ

1.PHPÀúÊ·
 a.1995ÄêÓÉLerdorf´´½¨£¬µ±Ê±ËûÊÇΪÁË´´½¨Ò»¸ö·ÃÎʼÆËãÆ÷
 b.1997Äê11Ô·¢ÐÐPHP 2.0£¬³ÆΪPHP-FI£¨¸öÈËÖ÷Ò³-±íµ¥½âÊÍÆ÷£©
 c.1998Äê6Ô·¢ÐÐPHP3.0£¬Ãû³ÆÓÉPersonal Home Page ±ä³É HyperText Preprocessor(³¬Îı¾Ô¤´¦ÀíÆ÷)
 d.2000Äê5ÔÂPHP4·¢²¼
 e.PHP5·¢²¼
2.php4,php5ÌØÐÔ
3 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ