Home  >  Article  >  Backend Development  >  实践二

实践二

WBOY
WBOYOriginal
2016-06-13 12:12:42975browse

PHP-表单的读写,File文件的操作等---ShinePans

实践一:


表单的操作:


wlcome_page.php

	<?php include("menu1.php");	?>	

Name         :
Age          :
Adress       :
Phone pnumber:


welcome_info.php:


	<font color="pink"><h1>Welcome!		<?php echo $_POST["name"]?>		<br>		<h1></h1>
</h1></font>	<font color="yellow"><h2>		You are 		<?php echo $_POST["age"]		 ?>	    years old.</h2></font>    <font color="green"><h2>Your Address is    	<?php echo $_POST["address"];    	?>    	.</h2></font><br>    <font color="blue"><h2>Your Phone number is     	<?php echo $_POST["phone_number"];    	?>    	.</h2></font><br>



menu1.php:

	<a href="http://localhost:8080/php_test/wlcome_page.php">Home</a>|	<a href="http://localhsot:8080/php_test/about1.php">About Us</a>|	<a href="http://localhost:8080/php_test/contact.php">Contact Us</a>	



表单显示效果,填写信息:




实践二

文件的上传,文件的读取:


open_close_file_test.php:

	<?php $num_of_char=0;	$file=fopen("test_files1.txt","r+");	//$file1=fopen("test_files2.txt","r") or exit("unable to open file!");	//fclose($file1);	/*	下面的代码是逐行读取文件的代码,	feof:判定是否读到了文件结束标志	fgets:逐行读取文件	*/	while(!feof($file))	{		echo fgets($file)."<br/>";	}	/*	字数判定;	*/	$file1=fopen("test_files1.txt","r");	while(!feof($file1))	{		if(fgetc($file1)!=' ')		$num_of_char++;	}	echo "The test_files1.txt have the number of ".$num_of_char." chars";	?>	




upload_file.php

	<?php if($_FILES["file"]["error"]>0)	{		echo "Error:".$_FILES["files"]["error"]."<br>";	}	else	{		echo "Upload:".$_FILES["file"]["name"]."<br>";		echo "Type:".$_FILES["file"]["type"]."<br>";		echo "Size:".($_FILES["file"]["size"]/1024)."kb<br>";		echo "Stored in:".$_FILES["file"]["tmp_name"];	}	?>	

效果显示:




上传后服务器返回的信息:




至此,表单的信息获取,文件的上传实践至此.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn