今天從phpclasses.org上發(fā)現(xiàn)的一個超牛的php類,這個類最特別的是可以用select語句來從xml和html文檔中讀取特定的數(shù)據(jù)。例如下面是一個例子:
<?php
/*
** htmlsql - example 1
**
** 一個查詢的簡單例子
*/
//包含類文件
include_once("../snoopy.class.php");
include_once("../htmlsql.class.php");
//創(chuàng)建對象
$wsql = new htmlsql();
// 連接上url
if (!$wsql->connect('url', '/')){
print 'error while connecting: ' . $wsql->error;
exit;
}
/* 執(zhí)行查詢
select * from a 讀取phpchina.cn首頁的html中的所有的<a>標(biāo)記
*/
if (!$wsql->query('select * from a ')){
print "query error: " . $wsql->error;
exit;
}
// 輸出結(jié)果:
foreach($wsql->fetch_array() as $row){
print_r($row);
/*
$row 是像下面的一個數(shù)組:
array (
[href] => /index.html
[tagname] => a
[text] => 首頁
)
*/
}
?>
這個類的作者:jonas john
個人主頁:http://www.jonasjohn.de/
年齡:20
新聞熱點
疑難解答