一、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>
<!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> 
<?php ini_set('display_errors', 1); error_reporting(E_ALL|E_STRICT); http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$title=$_POST['title']; $name =$_POST['name'];</span></strong> print "<p> hello <span style="color:#ff0000;">$title $name</span>"; ?> </body> </html>输入: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>
<!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> 
<?php ini_set('display_errors', 1); error_reporting(E_ALL|E_STRICT); http://blog.csdn.net/u014761420/article/details/<strong><span style="color:#ff0000;">$name=$_GET['name']; print "<p> hello $name";</span></strong> ?>
</body> </html>
二、相关函数学习
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 随机一个数