php实验报告一
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
华北科技学院管理学院实验报告册
实验报告
实验时间: 2015 年11 月 11 日节
一、实验运行环境
Windows2000++
二、实验目的
1、掌握正则表达式的使用方法
2、掌握php获取html表单数据的方法
3、掌握php中的文件处理的使用方法
4、掌握类的创建方法及应用
三、实验要求
1、某表单及验证表单的程序如3-1文件夹,请运行该程序并理解文件中的正则表达式。
$filename = 'hello/'; $somecontent = "我先被写入的!\r\n"; $somecontent1 = "我后被写入的!\r\n"; 1 a 2 a 3 a 4 a 5 a myf ile_name); } >
$myfile = $_FILES['myfile']['tmp_name']; if($myfile != "") { if(copy($myfile,$_FILES['myfile']['name'])) { echo "上传成功"; } else { echo "上传失败"; } unlink($myfile); } else { echo "没有可上传的文件"; } > 8、利用php中的文件处理技术编写程序如下:请运行该程序并理解。 $filename = 'hello/'; $somecontent = "我先被写入的!\r\n"; $somecontent1 = "我后被写入的!\r\n"; oo::$my_stat ic . " $foo = new Foo(); " $bar = new Bar(); print $bar->fooStatic() ; upl oad->errmsg(); }}> 12、php显示中文时,经常出现乱码,请编写一个编码转换类,从而实现编码的自动转换。 class changecode{ private $str; private $input; private $output; function __construct($input='',$output='gb2312'){ $this->input = $input; $this->output = $output; } protected function chgcode($str){ if($this->input != ''){ $this->str = iconv($input,$output,$str); }else{ $this->str = mb_convert_encoding($str,$output); } include_once ""; if($_POST['name'] != "范春喜"){ $tm -> refurbish('用户名错误'); }else{ $tm -> skipachange('登陆成功',''); } > class TakeMsg{ function __construct(){ } function simpleMsg($mess){ echo $mess; } function skipachange($mess,$url=NULL){ if(!is_null($url)){ echo ""; }else{ echo ""; } } function refurbish($mess,$sec=3,$url=NULL){ if(is_null($url)){ $hr = $_SERVER['HTTP_REFERER']; echo $mess.' echo '页面将于'.$sec.'秒后跳转。如果没有跳转,请点击这里返回'; echo ''; }else{ echo $mess.' echo '页面将于'.$sec.'秒后跳转。如果没有跳转,请点击这里返回'; echo ''; } } } $tm = new TakeMsg(); > include_once ""; $tm -> simpleMsg('欢迎光临'); >
";
"; "
"; "
";
';
';