php基礎教程——學習總結

來源:互聯網
上載者:User

標籤:php基礎教程   php表單傳送   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> <form action="handle.php" method="post"> <p> Name:<select name="title"> <option value="Mr">Mr</option> </select> <input type="text" name="name" size="20"/></p> <input type="submit" value="send"></form></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> 
<?phpini_set('display_errors', 1);error_reporting(E_ALL|E_STRICT);<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><a href=<strong><span style="color:#ff0000;">"handle.php?name=Charles</span></strong>">Charles</a></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> 
<?phpini_set('display_errors', 1);error_reporting(E_ALL|E_STRICT);<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 隨機一個數


php基礎教程——學習總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.