Home > php教程 > PHP源码 > body text

六间房的两个PHP面试题

PHP中文网
Release: 2016-05-25 17:05:24
Original
1953 people have browsed it

六间房的两个PHP面试题

<?php
/*=============================================================================
#     FileName: base64.php
#         Desc: 六间房笔试题一:读取一个文件,将其Base64编码,每76个字符加一个换行 
#       Author: HouYongZheng

#         Time: 2013-05-20 14:25
=============================================================================*/
header(&#39;Content-Type: text/html; charset=utf-8&#39;);
$body=file_get_contents(&#39;base64.txt&#39;);
$base_body=base64_encode($body);
$count=1;
for($i=0;$i
Copy after login

2. [代码]写一个函数,参数为$n,生成一个数组,其元素为1~$n,各元素位置随机排列,不得重复

<?php
/*=============================================================================
#     FileName: array.php
#         Desc: 六间房笔试题二:写一个函数,参数为$n,生成一个数组,其元素为1~$n,各元素位置随机排列,不得重复
#       Author: HouYongZheng

#         Time: 2013-05-20 15:01
=============================================================================*/
function rand_array($n){
	$array=array();
	$rand_array=array();
	for($i=1;$i<=$n;$i++){
		array_push($array,$i);
	}
	//return $array;
	for($i=0;$i
Copy after login

           


       


Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template