php´¦Àíxpath
1 <?php
2 $doc = new DOMDocument('1.0', 'utf-8');
3 $doc->load('./articles.xml');
4
5 $xpath = new DOMXPath($doc);
6 /*
7 * $xpath = domxml_open_file("articles.xml");
8 */
9 $arts = $xpath->query("/articles/article/title");
10
11 foreach ($arts as $art)
12 {
13 echo $art->nodeValue." ";
14 }
15 ?>
ÆäÖУ¬articles.xmlµÄÄÚÈÝÈçÏ£º
1 <?xml version="1.0" encoding="UTF-8"?>
2 <articles>
3 <article id="1">
4 <tags>
5 <tag>php</tag>
6 <tag>xpath</tag>
7 </tags>
8 <title>PHP XPath Example</title>
9 </article>
10 <article id="2">
11 <tags>
12 <tag>dom</tag>
13 <tag>dodocument</tag>
14 </tags>
15 <title>DomDocument Tutorial</title>
16 </article>
17 </articles>
Ïà¹ØÎĵµ£º
"&"£ºÊ¹ÓÃ"&"·ûºÅ½øÐеĴ«µØÖ·¸³ÖµÊµ¼ÊÉϾÍÊǶԱäÁ¿µÄÒ»ÖÖÒýÓ÷½·¨¡£ÔÚPHPÖУ¬ÒýÓÃÒâζ×ŶÔͬһ¸ö±äÁ¿µÄ²Ù×÷£¬Ò²¾ÍÊǶÔÓÚͬһ¸öÖµÀ´Ëµ£¬¿ÉÒÔͨ¹ýÒýÓõķ½·¨Ê¹Æä¾ßÓжà¸ö±äÁ¿Ãû¡£ÒýÓÃͨ³£·ÖΪÁ½ÖÖÀàÐÍ£¬¶Ô±äÁ¿µÄÒýÓü°¶Ôº¯ÊýµÄÒýÓá£
$this£ºÔÚ¶ÔÏóÖУ¬$thisÓÀÔ¶µ÷ÓÃËüµÄ¶ÔÏó×ÔÉíµÄÒýÓá£
parent:ÔÚ¶ÔÏñÖУ¬parent ......
×î½üÐèҪʹÓÃÏÂPHPÏà¹ØµÄ¶«Î÷£¬²éÕÒÁËһЩ×ÊÁÏ£¬ÏÖ½«PHPÅäÖ÷½·¨¼Ç¼һÏ£¬ÒÔÃâÒÔºóÍü¼Ç£¬ºÇºÇ£¬³õѧÕߣ¬¸÷λͬѧ²»ÒªÅÄש£¬¿ªÊ¼ÕýÌ⣬Ö÷Òª²Ù×÷ÈçÏ£º
1,°Ñphp-5.0.0-Win32.zip½âѹ·Åµ½C:\php
2,php.ini-dist¸ÄÃûΪphp.ini,ÕÒµ½µÚ438ÐÐ¸Ä³É extension_dir = c:\php\ext
3,È¥µô565ÐÐ;extension=php_mysql.dllÇ°ÃæµÄ";"×¢Ê ......
Ò»£º½á¹¹ºÍµ÷ÓÃ(ʵÀý»¯)£º
class className{} £¬µ÷Óãº$obj = new className();µ±ÀàÓй¹Ô캯Êýʱ£¬»¹Ó¦´«Èë²ÎÊý¡£Èç$obj = new className($v,$v2...);
¶þ£º¹¹Ô캯ÊýºÍÎö¹¹º¯Êý£º
1¡¢¹¹Ô캯ÊýÓÃÓÚ³õʼ»¯£ºÊ¹ÓÃ__construct()£¬¿É´ø²ÎÊý¡£
2¡¢µ«Îö¹¹º¯Êý²»ÄÜ´ø²ÎÊý£¨ÓÃÓÚÔÚÏúÈ¥Ò»¸öÀà֮ǰִÐÐһЩ²Ù×÷»ò¹¦ÄÜ£©¡£Îö¹¹º¯ÊýÓà ......
°²×°»·¾³£ºVMware Workstation 5.5.0 build-18463
Linux°æ±¾£ºRed Hat Enterprise Linux AS (2.6.9-42.EL)
Èí¼þ°æ±¾£ºMySQL5 - mysql-5.0.37.tar.gz
¡¡¡¡¡¡¡¡¡¡Apache2 - httpd-2.2.4.tar.gz
¡¡¡¡¡¡¡¡¡¡PHP5 - php-5.2.1.tar.gz
¡¡¡¡¡¡¡¡¡¡(½«ÒÔÉÏÎļþ±£´æÖÁ/home/tmpĿ¼)
[MySQL]
# cd /home/tmp (½øÈëѹËõ°ü ......
function getsock($strUrl,$arrParameter=array(),$strMethod="POST"){
if(!$strUrl||!$strMethod){ return "";}
$strMethod = strtoupper($strMethod);
$arrUrl = parse_url($strUrl);
if($arrUrl["port"]==0){$arrUrl["port"]=80;}
$fso = fsockopen($arrUrl["host"],$arrUrl["port"] ......