Heim  >  Artikel  >  php教程  >  php基础教程学习总结

php基础教程学习总结

WBOY
WBOYOriginal
2016-06-13 09:15:371022Durchsuche

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> 

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;
<?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> 
输入: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> 

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;
<?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>
?>
</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 随机一个数


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn