第一题第二题第三题第四题第五题
时间:2008-10-13
来源:互联网
[php]
#第一题
function read_file($path){
if(file_exists($path)){
//如果所给出的地址是一个文件则输出这个文件.
if(is_file($path)){
$show.= "$file"."<p>";
}else {//如果不是一个文件则说明是一个目录,则要循环输出该目录下或该目录的子目录下的文件.
$handle =opendir($path);//打开这个目录句柄
//读出这个目录下面的所有文件和目录
while (($file= readdir($handle))!=''){
//如果目录或文件名不是"."号\".."号和为空的话
if(($file!="..") && ($file!="") && ($file!=".")){
if(is_dir("$path/$file")){//再次判断所读到的元素是一个目录还是一个文件
//如果是一个目录则再次调用本函数(递归调用)
$show.=read_file("$path/$file");
}else{//如果它是一个文件
$show.= "$path/$file"."<p>";
}
}
}
//关闭目录句柄
closedir($handle);
}
}else {
echo "你输入的路径不正确";
}
return $show;
}
//调用该函数
//echo $display = read_file("../test_PHPWind6");
#第二题
function confer_date($date,$tag = '+',$days = '1'){
if(preg_match('/^\d{4}-\d{2}-\d{2}$/',$date)){ //验证输入的日期格式
$temp_date = explode('-', $date);
if(checkdate($temp_date['1'], $temp_date['2'], $temp_date['0'])){ //验证输入的日期是否正确
$stamptime = strtotime($date);
$offtime = $days*24*60*60;
switch ($tag)
{
case '+' : $that_time = $stamptime + $offtime; break;
case '-' : $that_time = $stamptime > $offtime ? $stamptime - $offtime : '你输入的天数太大'; break;
default : $that_time = '请正确的输入要计算的符号值!';
}
return $mytime = is_int($that_time) ? date('Y-m-d',$that_time) : $that_time;
}else return $mytime = '日期出错';
}else return $mytime = '日期格式出错';
}
//echo $tt = confer_date('2008-09-10','-','38');
#第三题
function check_email($email){
$domain_array = array('qq','sina');
$temp_email = explode('@', $email);
if(count($temp_email) == 2){
$username = $temp_email['0']; //用户名
$domain = $temp_email['1']; //邮箱服务器名
if(preg_match('/^\d*$/',$username)) return $mytime = '邮箱用户名不能全部为数字';
$temp_domain = explode('.', $domain);
if(preg_match('/^\d*$/',$temp_domain['0'])) return $mytime = '邮箱服务器名不能为纯数字';
if(in_array($temp_domain['0'],$domain_array)) return $mytime = '邮箱服务器名不能为QQ 或 sina ';
//将已经注册过的邮箱地址放入数组
$regis_email = array('[email protected]','[email protected]','[email protected]');
if(in_array($email,$regis_email)) return $mytime = '此邮箱地址已经有人注册';
}else return $mytime = '邮箱地址格式出错';
return $mytime = '邮箱地址可以注册';
}
//echo $ss = check_email('[email protected]');
#第四题
//select * from topic where userid in (select id from rank where newtopic = 1) and belongid=5
#第五题
//有一个最简单的方法,验证下从客户端输入的并且要作为查询条件的字符串.
$username = stripcslashes($_GET['username']);
$password = stripcslashes($_GET['password']);
mysql_query('select * from tablename where username='.$username .' and password = '.$password);[/php]
#第一题
function read_file($path){
if(file_exists($path)){
//如果所给出的地址是一个文件则输出这个文件.
if(is_file($path)){
$show.= "$file"."<p>";
}else {//如果不是一个文件则说明是一个目录,则要循环输出该目录下或该目录的子目录下的文件.
$handle =opendir($path);//打开这个目录句柄
//读出这个目录下面的所有文件和目录
while (($file= readdir($handle))!=''){
//如果目录或文件名不是"."号\".."号和为空的话
if(($file!="..") && ($file!="") && ($file!=".")){
if(is_dir("$path/$file")){//再次判断所读到的元素是一个目录还是一个文件
//如果是一个目录则再次调用本函数(递归调用)
$show.=read_file("$path/$file");
}else{//如果它是一个文件
$show.= "$path/$file"."<p>";
}
}
}
//关闭目录句柄
closedir($handle);
}
}else {
echo "你输入的路径不正确";
}
return $show;
}
//调用该函数
//echo $display = read_file("../test_PHPWind6");
#第二题
function confer_date($date,$tag = '+',$days = '1'){
if(preg_match('/^\d{4}-\d{2}-\d{2}$/',$date)){ //验证输入的日期格式
$temp_date = explode('-', $date);
if(checkdate($temp_date['1'], $temp_date['2'], $temp_date['0'])){ //验证输入的日期是否正确
$stamptime = strtotime($date);
$offtime = $days*24*60*60;
switch ($tag)
{
case '+' : $that_time = $stamptime + $offtime; break;
case '-' : $that_time = $stamptime > $offtime ? $stamptime - $offtime : '你输入的天数太大'; break;
default : $that_time = '请正确的输入要计算的符号值!';
}
return $mytime = is_int($that_time) ? date('Y-m-d',$that_time) : $that_time;
}else return $mytime = '日期出错';
}else return $mytime = '日期格式出错';
}
//echo $tt = confer_date('2008-09-10','-','38');
#第三题
function check_email($email){
$domain_array = array('qq','sina');
$temp_email = explode('@', $email);
if(count($temp_email) == 2){
$username = $temp_email['0']; //用户名
$domain = $temp_email['1']; //邮箱服务器名
if(preg_match('/^\d*$/',$username)) return $mytime = '邮箱用户名不能全部为数字';
$temp_domain = explode('.', $domain);
if(preg_match('/^\d*$/',$temp_domain['0'])) return $mytime = '邮箱服务器名不能为纯数字';
if(in_array($temp_domain['0'],$domain_array)) return $mytime = '邮箱服务器名不能为QQ 或 sina ';
//将已经注册过的邮箱地址放入数组
$regis_email = array('[email protected]','[email protected]','[email protected]');
if(in_array($email,$regis_email)) return $mytime = '此邮箱地址已经有人注册';
}else return $mytime = '邮箱地址格式出错';
return $mytime = '邮箱地址可以注册';
}
//echo $ss = check_email('[email protected]');
#第四题
//select * from topic where userid in (select id from rank where newtopic = 1) and belongid=5
#第五题
//有一个最简单的方法,验证下从客户端输入的并且要作为查询条件的字符串.
$username = stripcslashes($_GET['username']);
$password = stripcslashes($_GET['password']);
mysql_query('select * from tablename where username='.$username .' and password = '.$password);[/php]

answer.rar (1.49 KB)
作者: wanchun0222 发布时间: 2008-10-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28