ʹÓà PHP ´¦Àí XML ÅäÖÃÎļþ
ʹÓà PHP ´¦Àí XML ÅäÖÃÎļþ
ʹÓà XML ÅäÖÃÎļþÇáÒ×µØÅäÖà PHP Ó¦ÓóÌÐòºÍ¶ÔÏó
¼¶±ð£º Öм¶
Vikram Vaswani, ´´Ê¼ÈË, Melonfire
2007 Äê 11 ÔÂ 29 ÈÕ
XML ΪӦÓóÌÐòÅäÖÃÎļþÌṩÁËÒ»ÖÖ±ã½Ý¡¢Ò×Óõıí´ïÓïÑÔ¡£µ«ÓÐʱºò½«ÕâЩÐÅÏ¢ÌáÈ¡µ½ PHP ½Å±¾Öн«»áÃæ¶ÔÒ»¸ö²»Ð¡µÄÌôÕ½¡£ÕâÕýÊÇ XJConf for PHP °ü³öÏÖµÄÔÒò£ºËüÌṩÁËÒ»ÖÖ¶ÁÈ¡ XML ±àÂëÐÅÏ¢²¢Ö±½Ó½«ÆäÓÃÓÚÅäÖñêÁ¿¡¢Êý×éºÍ PHP ¶ÔÏóÕâÀà PHP Êý¾Ý½á¹¹µÄ API¡£±¾ÎĽéÉÜÁËÕâ¸ö°ü£¬²¢Í¨¹ýÔÚһЩʵ¼ÊÓ¦ÓóÌÐòÖеÄÓ¦ÓÃÀ´Ê¾·¶ÆäÓ÷¨£¬°üÀ¨ÅäÖø´ÔÓµÄÀàÊ÷ºÍ¹¹½¨»ùÓÚ Web µÄÅäÖýçÃæ¡£
¼ò½é
×÷ΪһÌõͨÓùæÔò£¬¿ª·¢ÈκÎÉÔ΢¸´ÔÓµÄÈí¼þʱ£¬×îºÃ»¨µãʱ¼äÈ·¶¨²úÆ·µÄÖØÒªÅäÖñäÁ¿£¬²¢½«Æä´Ó±ê×¼±äÁ¿Ãû³Æ¿Õ¼äÖÐÈ¡³öÀ´·Åµ½µ¥¶ÀµÄλÖá£ÕâÑù´¦Àíºó¾ÍÄÜÐγɼ¯ÖеÄÓ¦ÓóÌÐòÅäÖÃÐÅÏ¢´æ´¢¿â£¬´Ó¶ø¼ò»¯ÔÚ²»Í¬»·¾³Öй¤×÷ʱ¶Ô²úÆ·µÄÐ޸ġ£»¹ÓÐÖúÓÚ¿ª·¢ÈËÔ±ÊìϤºÍÀí½â²úÆ·³É¹¦ÔËÐÐËùÐèÒªµÄÖØÒªÐÅÏ¢¡£
´«Í³ÉÏ£¬ÅäÖñäÁ¿´æ´¢ÔÚÒ»¸ö£¨»ò¶à¸ö£©ÅäÖÃÎļþÖС£ÕâЩ±äÁ¿³£³£Óà XML ±íʾ£¬XML ÌṩÁËÒ»¸öÁé»îµÄ¿ò¼ÜÔÊÐíÎĵµ×÷ÕßʹÓÃ×Ô¶¨ÒåµÄ±êÇ©ºÍ±ê¼ÇÃèÊöÄÚÈÝ¡£¶àÊýÇé¿öÏ£¬¿ª·¢ÈËÔ±»¹ÐèÒª½¨Á¢ÓëÕâЩ XML ÅäÖÃÎļþ½»»¥µÄÓû§½Ó¿Ú£¬¶ÁÈ¡ºÍʹÓðüº¬µÄÅäÖÃÊý¾Ý¡£
XJConf for PHP ¿É°ïÖú PHP ¿ª·¢ÈËÔ±Íê³ÉÕâÏîÈÎÎñ¡£Õâ¸ö¿ªÔ´µÄ°üÌṩÁËÒ»ÖÖ API£¬´ÓÅäÖÃÎļþÖÐÌáÈ¡ XML ±àÂëµÄÐÅÏ¢£¬×ª»¯³ÉÔÉúÊý¾Ý½á¹¹Ö±½ÓÔÚÓ¦ÓóÌÐòÖÐʹÓá£Í¬ÑùµØ£¬ËüҲΪËùÓÐµÄ PHP Ó¦ÓóÌÐòÌṩÁËÒ»ÖÖ½¡×³µÄ¡¢Ò×ÓõIJ¿¼þ¡£
»ØÒ³Ê×
°²×°ÐèÒªµÄÈí¼þ
XJConf °üÓÉ Frank Kleine ºÍ Stephan Schmidt ά»¤£¬°´ÕÕ GNU LGPL ÐÒéÔÚ PHP ÉçÇø·¢²¼¡£ËüÐèÒª PHP 5.0£¨»ò¸ü¸ß°æ±¾£©£¬×î¼òµ¥µÄ°²×°·½·¨ÊÇʹÓà PEAR ×Ô¶¯°²×°³ÌÐò£¬ºóÕßĬÈÏÇé¿öÏ°üº¬ÔÚ PHP ÖС£°²×°Ö»ÐèÔÚ shell Ìáʾ·ûÏÂÊäÈëÏÂÁÐÃüÁî¼´¿É£º
shell> pear channel-discover pear.php-tools.net
shell> pear install pat/XJConfForPHP-alpha
PEAR °²×°³ÌÐò½«Á¬½Óµ½ÐµÄͨµÀ£¬ÏÂÔØÕâ¸ö³ÌÐò°ü²¢°²×°µ½ÏµÍ³ÖÐÊʵ±µÄλÖᣱ¾ÎÄʹÓõÄÊÇ XJConf for PHP V. 0.2.0¡£
ÊÖ¶¯°²×°ÐèÒª·ÃÎÊÖ÷Ò³£¬ÏÂÔØÔ´´úÂëѹËõ°ü£¬ÊÖ¶¯½âѹµ½Ä¿±êλÖ᣿ÉÒÔÔÚ±¾ÎÄµÄ ²Î¿¼×ÊÁÏ ²¿·ÖÕÒµ½¸Ã³ÌÐò°üµÄÖ÷Ò³ÒÔ¼°ÕýÔÚ¿ª·¢°æ±¾µÄÁ´½Ó¡£ÐèҪעÒâµÄÊÇÊÖ¹¤°²×°Ö®Ç°±ØÐë¶Ô PEAR ³ÌÐò°üµÄ×éÖ¯½á¹¹ÓÐËùÁ˽⡣
×îºóÒ»µãÒªÇó£ºXJConf for PHP ÐèÒªÆôÓà PHP µÄ xmlreader À©Õ¹¡£PHP 5.1.0 »òÒÔÉϰ汾ĬÈÏ
Ïà¹ØÎĵµ£º
ÔÚwindowsÏ°²×°image magic µÄphpÀ©Õ¹ imagick, Ê×ÏÈÐèÒªÏÂÔØphp_imagick.dllÎļþ.Õâ¸ödllÎļþ·Ç³£¹Ø¼ü.
Èç¹ûÏÂÔØÁË´íÎóµÄphp_imagick.dll.°²×°¾Í»áʧ°Ü.ÎÒ¾ÍÊÇÏÂÔØÁËN¸öÕâÑùµÄdllÎļþ¶¼Î´ÄÜ°²×°³É¹¦.×îºóÖÕÓÚ¸øÎÒÕÒµ½ÕýÈ·µÄdllÎļþÁË
ÏÂÔصØÖ·:http://valokuva.org/outside-blog-content/imagick-windows-builds ......
Ϊ PHP Ìí¼ÓÀ©Õ¹¿âÊÇÒ»¼þ¼òµ¥µÄÊÂÇé¡£²»¹ýÊ×ÏÈÄã×îºÃ»áÒ»µãµãC/C++±à³Ì¼¼Êõ£¬²¢ÇÒ¶ÔMakefileÓÐÒ»¶¨µÄÁ˽⡣
ÒÔÏÂÊÇÔÚ Linux ϵÄÒ»¸ö¼òµ¥Àý×Ó£º
Ê×ÏÈ£¬½øÈë php Ô´´úÂëĿ¼£¨¼ÙÉèΪ PHP_SRC£¬ÒÔÏÂͬ£©£¬Ê¹Óà php ×Ô´øµÄ ext_skel ¹¤¾ßÉú³ÉÒ»¸öÐÂÀ©Õ¹ mk4php£º
cd PHP_SRC/etc;
./ext_skel --extname=mk4php
Õý³£Ç ......
IPV4 ¿ÉÒÔ¿´×ö4¸ö256½øÖƵÄÊý×Ö, ¿ÉÒÔ°´³£¹æµÄ½øÖÆת»»»»Ëã³ÉÊ®½øÖÆ.
Èç 192.168.1.1 »»Ëã³É10½øÖÆ:
192*256*256*256 + 168*256*256+1*256+1
Æäʵ¼ÆËã»ú¸üÉó¤ÒÆλºÍÓë»òÔËËã. ¿ÉÒԸĽøËã·¨ÈçÏÂ.
IP ת³¤ÕûÐÍ
public ipToInt($sIP)
{
$aIP = explode('.',$sIP);
$iIP = ($aIP[0] << 24) | ($aIP[1] ......
php¶ÔxmlÎļþÖнڵãµÄɾ³ý\±à¼
ʹÓÃgetElementsByTagName()·½·¨É¾³ý\±à¼XML½Úµã
Èý¸öÎļþ£º
1.root.xml
2.remove.php —— ɾ³ý½Úµã
3.replace.php —— Ìæ»»½Úµã
root.xml
<root>
<child1>child1 content</child1>
<child2>child2 content</child2>
& ......
±È½Ï£º
1. DTD
a. ×îÔçµÄXML Contraint
b. ÓÉW3C¶¨Òå
C. ·Ç³£¼òµ¥
2. XML Schema
a. Ä¿Ç°Ó¦ÓÃ×î¹ãµÄXML Contraint
b. ÓÉW3C¶¨Òå
c. ºÜÁé»î£¬µ«·Ç³£¸´ÔÓ
3. Relax NG
a. ÊǸöÒ°º¢×Ó£¬²»ÊÇÓÉW3C¶¨Òå
b. ·Ç³£·Ç³£¼òµ¥Ö±¹Û
c. ¶ÔÓÚÐèҪƵ·±¶¨ÒåContraintµÄEngineer·Ç³£ºÏÊÊ
Ï໥ת»¯£º
1. XML Document -> DTD ......