PHP課堂-實驗四

來源:互聯網
上載者:User
PHP課堂--實驗4

PHP課堂--實驗4

實驗目的:

掌握PHP中函數的基本應用,注意參數傳遞過程中傳值和傳引用的區別

掌握PHP中表單的基本應用,包括get和post兩種方式,注意這兩種方式的區別

掌握PHP中檔案的開啟,關閉和上傳操作

掌握PHP中cookie和session的基本使用

實驗內容:

1.編寫一個php動態網頁面,在html標記中用先嵌入一段php代碼,給變數$x賦一個文本數值;然後把$x的數值作為一個html表單中的文本型輸入框的value屬性值。

提示:

使用:

2、使用form進行不同頁面動態互動(兩種不同方式,get和post的區別,)

建立前後2個頁面,通過使用form和sumbit按鈕來實現:將前一頁輸入框中的值提交給後一頁進行顯示。

提示:

1)前頁:

頁面跳轉:exam4_2_post.php";echo $_POST["username"];?>


3.原始碼:

exam4_3.php

排列輸入數位大小順序

排序結果為:
";while(list($key,$v) = each($x)){echo "$key $v
";}}?>


4.原始碼:

exam4_4.php

檔案上傳

upload_file.php 0){echo "返回碼:".$_FILES["file"]["error"]."
";}else {echo "上傳:".$_FILES["file"]["name"]."
";echo "類型:".$_FILES["file"]["type"]."
";echo "大小:".($_FILES["file"]["size"]/1024)."kb
";echo "臨時檔案".$_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 "儲存在:"."d:/".$_FILES["file"]["name"];}}?>






  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.