Home  >  Article  >  Backend Development  >  PHP basic tutorial - learning summary_PHP tutorial

PHP basic tutorial - learning summary_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:07:57850browse

php basic tutorial - learning summary

1. PHP and forms

1.POST method to send data manually:

Some differences between the two:

GET:

1. Gather information and send it as part of the URL

2. The number of transmissions is limited

3. Public transmission, such as password information will be exposed

4. The created form can be added as a bookmark.

POST:

1. The transmitted information cannot be seen by users


Usage example:

html file: 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 file: 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> 
Enter: myname

Result: hello Mr myname

2.GET transfer data

<!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 file: 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> 


2. Related function learning

1. Format values:

round (the number to be formatted, retaining the number of decimal points);

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

number_format(number, number of decimal points, symbol to replace decimal point, thousands separator)

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

2. Random function rand()

eg:rand(0, 100);//Generate a random number from 0-100


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/953328.htmlTechArticlephp basic tutorial - learning summary 1. PHP and form 1.POST method to send data manually: Partial differences between the two : GET: 1. Gather the information and transmit it as part of the URL 2. The number of transmissions is limited...
Statement:
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