}
for($i=0;$i<count($rows)-1;$i++){ //去掉首行
$temp[]=$rows[$i];
}
return $temp;
}
}
function close(){
$this=$nothing;
}
}
//把段落文本格式化为一行文本,便于存储
function p2row($t){
$t=nl2br(stripslashes(htmlspecialchars($t)));
for($i=0;$i<strlen($t);$i++){
$c=substr($t,$i,1);
if(ord($c)==10) $c=" ";
$tempstr.=$c;
}
return $tempstr;
}
?>
----------------------------------
db是我们自定义的本文数据对象,包括六个方法:createdb(),opendb(),insertline(),readall().revread(),close();
db->createdb(string filename)
用法例:<?
include("textfun.inc");
$mydb=new db;
$mydb->createdb("UserInfo.php");
?>
这个方法创建了一个文件UserInfo.php,首行是<? die('ACCESS DENIED!');?>
db->opendb(string filename)
用法例:<?
include("textfun.inc");
$mydb=new db;
$mydb->opendb("UserInfo.php");
?>
这个方法以追加模式“打开”了数据文件UserInfo.php,如果这个文件不存在,则被创建。
因此,这个方法可以取代createdb()方法。(但千万别删了class db{ }里面的createdb()函数哦:P)
db->insertline(string VarString)
用法例:<?
include("textfun.inc");
$theline="email=ask4more@13.net&nickname=redfox&realname=阿鼎&url=http://NetNote.oso.com.cn";
parse_str($theline);//构造环境变量
$mydb=new db;
$mydb->opendb("UserInfo.php");
$mydb->insertline("nickname|realname|email|url");
?>







