//方法二
$content = file_get_contents('test.txt');
//方法二
$content = file_get_contents('test.txt');
//fopen 读取文件实例
$path ='a.txt';
$fp=fopen($file,"r");//以只读的方式打开文件
while(!(feof($fp)))
{
$text=fgets($fp);//读取文件的一行
echo $text;
}
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>php教程提取文章内容图片地址正则表达式</title>
</head>
class mysql{
private $db_host; //数据库主机
private $db_user; //数据库用户名
private $db_pwd; //数据库密码
private $db_database; //数据库名
private $conn; //数据库连接标识;
private $sql; //sql执行的语句
private $result; //query的资源标识符
private $coding; //数据库编码,gbk,utf8,gb2312
private $show_error = true; //本地调试使用,打印错误
include('global.php');
if($_post['sub']){
$user = $_post['username'];
$pwd = md5($_post['password1'].$user);
$email = $_post['email'];
$q = $mysql->query("insert into `hl`.`hl_member`(`id`,`username`,`password`,`email`)values (null,'$user','$pwd','$email');");
if($q){
setcookie('login',$user);
$prompt_msg->p('恭喜您,亲爱的会员,您已经注册成功!','index.php','现在去首页。','http://www.phprm.com','先去论坛逛逛!');
}else{
$prompt_msg->p('非常抱歉,系统发生故障!');
}
}
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.phprm.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>ajax+php验证用户名重复代码实例</title>
/*
create table `test`.`cn_user` (
`id` int not null auto_increment ,
`username` varchar( 20 ) not null ,
`times` date null ,
primary key ( `id` )
) engine = myisam
如果是用smarty模板的朋友可以如下调用
很容易看懂吧。原理很简单,首先是查询目录所有文件或目录,如果是文件就删除了,如果是目录看看是不是空目录,如果是的删除,否则再调用本函数一次类推,就实例了删除不是空目录的功能了。
//mssql server与php连接
//mysql数据库连接
$host = 'localhost';
$user_name = 'root';
$password = 'admin';
$conn = mysql_connect($host,$user_name,$password);
if(!$conn)
{
die('数据库连接失败:<br/>'.mysql_error());
}
echo '数据库连接成功!继续操作...';