PHP课堂-实验四
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)前页:
页面跳转:
提交按钮:
2)后页:
显示前一页传来的参数的方法:
3、使用form进行相同页面动态交互。
使用循环将用户输入的4个数由小到大排序显示。
提示:
本页的动态交互:不需要action,直接:
假设我们的提交按钮是:
则通过$_POST[“bt1”]可获得页面的提交情况:
if(isSet($_POST["bt1"]))//已点击了提交按钮,此值=真,否则为假。
4、文件上传
提示:
创建一个文件上传表单,注意enctype="multipart/form-data">(表示表单需要二进制数据);
进行文件上传的操作,注意$_FILES变量和参数的使用,文件上传过程中先把文件存放在服务器的临时目录,$_FILES[“file”][“tmp_name”],然后再利用move_uploaded_file()拷贝到指定目录;
提高要求,在文件上传过程中,对于文件类型,文件大小进行限制,如只允许小于100k的文件。
5.按照课件上面的cookie和session例子,了解cookie和session的基本用法
1、源代码:exam4_1.php
<?php $x = "Hello world!!!"; ?>1.编写一个php动态页面,在html标记中用先嵌入一段php代码,给变量$x赋一个文本数值;然后把$x的数值作为一个html表单中的文本型输入框的value属性值。<input type="text" name="x" size="32" value="<?php echo $x;?>">
2.源代码:exam4_2.php

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

Use Java's File.length() function to get the size of a file. File size is a very common requirement when dealing with file operations. Java provides a very convenient way to get the size of a file, that is, using the length() method of the File class. . This article will introduce how to use this method to get the size of a file and give corresponding code examples. First, we need to create a File object to represent the file we want to get the size of. Here is how to create a File object: Filef

How to convert php blob to file: 1. Create a php sample file; 2. Through "function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} ” method can be used to convert Blob to File.

Use Java's File.renameTo() function to rename files. In Java programming, we often need to rename files. Java provides the File class to handle file operations, and its renameTo() function can easily rename files. This article will introduce how to use Java's File.renameTo() function to rename files and provide corresponding code examples. The File.renameTo() function is a method of the File class.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Use java's File.getParent() function to get the parent path of a file. In Java programming, we often need to operate files and folders. Sometimes, we need to get the parent path of a file, which is the path of the folder where the file is located. Java's File class provides the getParent() method to obtain the parent path of a file or folder. The File class is Java's abstract representation of files and folders. It provides a series of methods for operating files and folders. Among them, get

Use java's File.getParentFile() function to get the parent directory of a file. In Java programming, we often need to operate files and folders. When we need to get the parent directory of a file, we can use the File.getParentFile() function provided by Java. This article explains how to use this function and provides code examples. File class in Java is the main class used to operate files and folders. It provides many methods to obtain and manipulate file properties
