Home > php教程 > php手册 > body text

php基础教程学习总结

WBOY
Release: 2016-06-13 09:15:37
Original
1022 people have browsed it

php基础教程——学习总结

一、php和表单

1.POST方法手动发送数据:

二者部分区别:

GET:

1.将信息聚集起来作为URL一部分传送

2.传送数量有限

3.公开传送,诸如密码信息会暴露

4.创建的表单可以添加为书签。

POST:

1.传递的信息用户看不到


用法示例:

html文件:ws.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>test</title>
<body> 



</body> 
</html> 
Copy after login

php文件:handle.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>test</title>
</head> 

<body>&#160;
Copy after login
Copy after login
<?php

ini_set(&#39;display_errors&#39;, 1);
error_reporting(E_ALL|E_STRICT);
http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$title=$_POST[&#39;title&#39;];
$name =$_POST[&#39;name&#39;];</span></strong>

print "<p> hello <span style="color:#ff0000;">$title $name</span>";
?>
</body> 
</html> 
Copy after login
输入:myname

结果:hello Mr myname

2.GET传送数据

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>test</title>
<body> 

<ul>
 <li><span style="color:#ff0000;">"handle.php?name=Charles</span></strong>">Charles</li>
</ul> 


</body> 
</html> 
Copy after login

php文件:handle.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>test</title>
</head> 

<body>&#160;
Copy after login
Copy after login
<?php

ini_set(&#39;display_errors&#39;, 1);
error_reporting(E_ALL|E_STRICT);

http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$name=$_GET[&#39;name&#39;];
print "<p> hello $name";</span></strong>
?>
Copy after login
</body> 
</html> 
Copy after login


二、相关函数学习

1.格式化数值:

round(要格式化的数字 , 保留小数点位数);

eg:$test=5.555555555; round(test, 2); // 5.55

number_format(数字, 小数点位数, 代替小数点的符号, 千位分隔符)

eg:number_format("10000000", 2 ,"," ,".");// 10.000.000,00

2.随机函数rand()

eg:rand(0, 100);//产生0-100 随机一个数


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!