php实验报告三Word下载.docx
- 文档编号:7863682
- 上传时间:2023-05-09
- 格式:DOCX
- 页数:27
- 大小:845.79KB
php实验报告三Word下载.docx
《php实验报告三Word下载.docx》由会员分享,可在线阅读,更多相关《php实验报告三Word下载.docx(27页珍藏版)》请在冰点文库上搜索。
functioncheckregemail(emails){
varstr=emails;
varExpression=/\w+([-+.'
]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
functionchkreg(form,label){
if(label==4||label=="
all"
){
if(form.email.value=="
"
check_email.innerHTML="
请输入E-mail地址!
;
form.email.style.backgroundColor="
#F1B000"
returnfalse;
}elseif(!
checkregemail(form.email.value)){
check_email.innerHTML="
邮箱地址的格式不正确!
form.email.style.backgroundColor="
returnfalse;
check_email.innerHTML="
#FFFFFF"
if(label==5||label=="
if(form.mtel.value=="
check_mtel.innerHTML="
请输入电话号码!
form.mtel.style.backgroundColor="
}elseif(!
checkregtel(form.mtel.value)){
电话号码的格式不正确!
}elseif(isNaN(form.mtel.value)){
check_mtel.innerHTML="
电话号由数字组成!
}else{
}
}
if(label==6||label=="
if(form.gtel.value=="
check_gtel.innerHTML="
form.gtel.style.backgroundColor="
checkregtels(form.gtel.value)){
check_gtel.innerHTML="
Index.php的核心代码是:
<
formname="
reg_check"
method="
post"
action="
t3-2index_print.php"
onSubmit="
returnchkreg(reg_check,'
all'
)"
>
tablewidth="
550"
height="
270"
border="
0"
align="
center"
cellpadding="
cellspacing="
/tr>
<
tr>
tdheight="
30"
<
divalign="
right"
Email:
/div>
/td>
colspan="
2"
left"
&
nbsp;
inputtype="
text"
name="
email"
size="
20"
onBlur="
chkreg(reg_check,4)"
fontcolor="
#FF0000"
*<
/font>
#999999"
divid="
check_email"
style="
color:
固定电话:
gtel"
chkreg(reg_check,6)"
check_gtel"
手机:
mtel"
chkreg(reg_check,5)"
check_mtel"
tdwidth="
100"
image"
src="
t3-2images/1.jpg"
340"
imgsrc="
t3-2images/2.jpg"
width="
56"
onClick="
reg_check.reset()"
cursor:
hand"
/>
/table>
/form>
Index_ok.php的核心代码是:
765"
229"
22"
padding-left:
10px"
spanclass="
style4"
/span>
tdalign="
class="
?
phpecho$_POST[email];
phpecho$_POST[gtel];
strong>
/strong>
phpecho$_POST[mtel];
结果如图:
3、字符串:
$text="
华北科技学院电子商务B11-1、2、3班电子商务应用开发技术课程"
,请编写程序截取该字符串的前16个字。
代码如下:
metahttp-equiv="
Content-Type"
content="
text/html;
charset=gb2312"
/>
php
$str="
functionmsubstr($str,$start,$len){
$tmpstr="
$strlen=$start+$len;
for($i=0;
$i<
$strlen;
$i++){
if(ord(substr($str,$i,1))>
0xa0){
$tmpstr.=substr($str,$i,2);
$i++;
}else
$tmpstr.=substr($str,$i,1);
return$tmpstr;
functionshowShort($str,$len)
{
$tempstr=msubstr($str,0,$len);
if($str<
$tempstr)
$tempstr.="
/"
return$tempstr;
echo$tempstr;
echoshowShort($str,27);
?
结果图如下:
4、某字符串:
$pizza="
a1a2a3a4a5a6"
//通过空格分隔,请编写程序以空格作为分隔符分隔该字符串并分别输出。
$abc=explode("
"
$pizza,6);
print_r($abc);
5、某表单如下,请编写获取表单的程序:
html>
head>
title>
PHP与Web表单的综合应用<
/title>
styletype="
text/css"
!
--
body,td,th{
font-size:
12px;
body{
margin-left:
5px;
margin-top:
margin-right:
margin-bottom:
-->
/style>
/head>
body>
formaction="
index.php"
form1"
enctype="
multipart/form-data"
405"
24"
1"
bordercolor="
bgcolor="
trbgcolor="
#FFCC33"
103"
25"
姓名:
inputname="
user"
type="
id="
maxlength="
性别:
sex"
radio"
value="
男"
checked>
男
女"
女<
密码:
289"
pwd"
password"
学历:
selectname="
select"
optionvalue="
初中"
初中<
/option>
高中"
高中<
专科"
专科<
本科"
selected>
本科<
研究生"
研究生<
博士生"
博士生<
硕士生"
硕士生<
/select>
爱好:
fond[]"
checkbox"
电脑"
电脑
音乐"
音乐
旅游"
旅游
其他"
其他<
个人简介:
textareaname="
intro"
cols="
28"
rows="
4"
/textarea>
tralign="
submit"
提交"
&
reset"
submit2"
重置"
/body>
/html>
主要代码:
if(($_POST["
]=="
)&
($_POST["
fond"
]
=null)){
echo"
姓名:
.$_POST["
]."
br/>
性别:
密码:
学历:
爱好:
for($i=0;
$i<
count($_POST["
]);
$i++)
echo$_POST["
[$i]."
echo"
个人简介:
6、利用ajax或JQuery实现表单验证。
运行3-6文件夹中的程序并理解ajax或JQuery实现表单验证的方法。
7、编写程序利用copy函数实现文件的上传。
Php1代码:
charset=gb2312"
文件上传<
php
if($_POST['
post_flag'
]==1)
{
$a=copy($myfile,"
upload_file/"
.$myfile_name);
formenctype="
action="
index2.php"
您的大名:
inputtype=textname=user>
br>
文件名称:
myfile"
file"
hidden"
post_flag"
Php2代码:
$myfile=$_FILES['
myfile'
]['
tmp_name'
];
if($myfile!
="
)
if(copy($myfile,$_FILES['
name'
]))
上传成功"
上传失败"
unlink($myfile);
没有可上传的文件"
8、利用php中的文件处理技术编写程序如下:
请运行该程序并理解。
$filename='
hello/1.txt'
$somecontent="
我先被写入的!
\r\n"
$somecontent1="
我后被写入的!
//首先我们要确定文件存在并且可写
if(is_writable($filename)){
//在这个例子里,将使用只写模式打开$filename
//文件指针将会在文件的开头,如果原来文件中有其他数据,则会被删除
if(!
$handle=fopen($filename,"
w"
)){
print"
不能打开文件$filename"
exit;
}//将$somecontent写入到我们打开的文件中。
fwrite($handle,$somecontent)){
不能写入到文件$filename"
成功地将\"
$somecontent\"
写入到文件$filename<
fclose($handle);
$handle=fopen($filename,"
);
//再次打开
//继续打开文件写入另外一个字符串,原来写入的数据则被清除
fwrite($handle,$somecontent1);
$somecontent1\"
写入到文件$filename"
}else{
文件$filename不可写"
}?
9、请编写程序实现动态页面转化为静态页面。
Html代码:
{title}<
{file}
Php代码:
$title="
标题"
$file="
文件"
$fp=fopen("
temp.html"
"
r"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- php 实验 报告