PHP Programming Basics Experiment 2: PHP Basic Syntax Programming (1)

Experiment 2-1 PHP basic syntax programming (1)

1. Experimental hours

2 hours

2. Experimental purpose

Master the definition rules of CSS styles, selector types, and reference methods of style files.

3. Experimental equipment

PC computer, equipped with Win10 operating system, Word2019, PHPStudy+eclipse for php

4.Experimental content and procedures

( 1 )Experimental content

Implement the interface shown in the figure below.

( 2 ) Experimental steps

1. In the D:\phpstudy_pro\WWW folder, create a new file named Experiment 2-1.php

2. Go to eclipse for php , open the file, and write code:

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
    <title>学生个人信息</title>
    <style type="text/css">
		.STYLE1{font-size: 20px;font-family:"黑体";color:blue;}
		.STYLE2{font-size: 15px;font-family:"幼圆";}
		table{
			border: 0;
			background-color: #CCFFCC;
			width: 400px;
			}
     </style>
</head>
<body>
	<form name="form" method="post" action="">
		<table align="center">
			<tr>
				<td colspan="2" bgcolor="#999999"><div align="center" class="STYLE1">学生个人信息</div></td>
			</tr> 
			<tr>
				<td width="120" class="STYLE2">学号:</td>
				<td><input name="XH" type="text" value="181101"></td>
			</tr> 
			<tr>
				<td class="STYLE2">姓名:</td>
				<td><input name="XM" type="text" value="王林"></td>
			</tr> 
			<tr>
				<td class="STYLE2">性别:</td>
				<td>
					<input name="SEX" type="radio" value="男" checked="checked">男
					<input name="SEX" type="radio" value="女">女
				</td>
			</tr>
			<tr>
				<td class="STYLE2">出生日期:</td>
				<td><input name="Birthday" type="text" value="1999-05-06"></td>
			</tr>
			<tr>
				<td class="STYLE2">所学专业:</td>
				<td>
					<select name="ZY">
						<option>计算机</option>
						<option>软件工程</option>
						<option>信息管理</option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="STYLE2">所学课程:</td>
				<td>
					<select name="KC" size="3" multiple>
						<option selected>计算机导论</option>
						<option selected>数据结构</option>
						<option>数据库管理</option>
						<option>操作系统</option>
						<option>计算机网络</option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="STYPE2">备注:</td>
				<td><textarea name="BZ">团员</textarea></td>
			</tr>
			<tr>
				<td></td>
				<td>
					<input name="XQ" type="checkbox" value="听音乐" checked="checked">听音乐
					<input name="XQ" type="checkbox" value="看小说">看小说
					<input name="XQ" type="checkbox" value="上网">上网
				</td>
			</tr>
			<tr>
				<td align="center" clospan="2">
					<input type="submit" name="button1" value="提交">
					<input type="reset" name="button2" value="重置">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
<?php 
?>

 3. Open the browser, enter: http://localhost/ Experiment 2-1.php in the address bar , and click Enter .

 

5. Experiment summary and experience

  1. Be familiar with and skillfully use the form tags in HTML5.
  2. It is best to write the rendering effect of the page in CSS to make it clearer.
  3. Start Apache before running, otherwise it will not be accessible.
  4. After opening the browser to access, the problem of garbled characters appears. Just change the encoding format of the browser and the encoding format of the file to be consistent (open the file with Notepad->Save As->Select UTF-8 as the encoding format->Replace)

Please give me some advice from all the great masters! ! !

By the way: the html code in the php file needs to be written completely (with a complete frame <!DOOTYPEHTML><html><head><title>...</title></head><body>... </body></html>)?

Guess you like

Origin blog.csdn.net/pzcxl/article/details/127045518