PHP class-experiment 4PHP class-experiment 4 & nbsp; objective: to master the basic application of functions in PHP, pay attention to the passing of parameters & #20540; the difference between passing references and understanding the basic applications of forms in PHP, including get and post methods. Note the difference between the two methods to understand how to open files in PHP, close and upload the cookies and ses PHP class in PHP-experiment 4
PHP class-experiment 4
Purpose:
Measure the test taker's knowledge about the basic applications of functions in PHP. pay attention to the differences between passing values and transferring references during parameter transfer.
Understand the basic applications of forms in PHP, including get and post methods. note the differences between the two methods.
Understanding how to open, close, and upload files in PHP
Understanding the basic usage of cookies and sessions in PHP
Lab content:
1. compile a php dynamic page, embed a piece of php code in the html tag, and assign a text value to the variable $ x; then, the value of $ x is used as the value attribute value of the text input box in an html form.
Tip:
Usage:
2. use form for dynamic interaction between different pages (the difference between get and post ,)
Create two pages, and use the form and sumbit buttons: submit the values in the input box of the previous page to the next page for display.
Tip:
1) previous page:
Page jump:Exam4_2_post.php "; Echo $ _ POST [" username "];?>
3. source code:
Exam4_3.php
Sort the order of input numbers
The sorting result is:
"; While (list ($ key, $ v) = each ($ x) {echo" $ key $ v
";}}?>
4. source code:
Exam4_4.php
File UploadUpload_file.php
0) {echo "return code:". $ _ FILES ["file"] ["error"]."
";} Else {echo" upload: ". $ _ FILES [" file "] [" name "]."
"; Echo" type: ". $ _ FILES [" file "] [" type "]."
& Quot; echo & quot; size: & quot;. ($ _ FILES [& quot; file & quot;] [& quot; size & quot;]/1024). & quot; kb
"; Echo" temporary file ". $ _ FILES [" file "] [" tmp_name "]."
"; If (file_exists (" d :/". $ _ FILES ["file"] ["name"]) {echo $ _ FILES ["file"] ["name"]. "already exists. ";} else {move_uploaded_file ($ _ FILES [" file "] [" tmp_name "]," d :/". $ _ FILES ["file"] ["name"]); echo "saved in :". "d :/". $ _ FILES ["file"] ["name"] ;}}?>