| 
 一、基础题1. 写出如下程序的输出结果
 <?
 $str1 = null;
 $str2 = false;
 echo $str1==$str2 ? '相等' : '不相等';
 $str3 = '';
 $str4 = 0;
 echo $str3==$str4 ? '相等' : '不相等';
 $str5 = 0;
 $str6 = '0';
 echo $str5===$str6 ? '相等' : '不相等';
 ?>
 phperz~com 2. 写出如下程序的输出结果
    
        
            | 以下为引用的内容: <?
 $a1 = null;
 $a2 = false;
 $a3 = 0;
 $a4 = '';
 $a5 = '0';
 $a6 = 'null';
 $a7 = array();
 $a8 = array(array());
 echo empty($a1) ? 'true' : 'false';
 echo empty($a2) ? 'true' : 'false';
 echo empty($a3) ? 'true' : 'false';
 echo empty($a4) ? 'true' : 'false';
 echo empty($a5) ? 'true' : 'false';
 echo empty($a6) ? 'true' : 'false';
 echo empty($a7) ? 'true' : 'false';
 echo empty($a8) ? 'true' : 'false';
 ?>
 |  php程序员站
 3. 写出如下程序的输出结果
 
 
    
        
            | 以下为引用的内容: <?
 $test = 'aaaaaa';
 $abc = & $test;
 unset($test);
 echo $abc;
 ?>
 |  
 4. 写出如下程序的输出结果
 
    
        
            | 以下为引用的内容: php程序员之家 <?$count = 5;
 function get_count(){
 static $count = 0;
 return $count++;
 }
 echo $count;
 ++$count;
 echo get_count();
 echo get_count();
 ?>
 |  
 5. 写出如下程序的输出结果
 
    
        
            | 以下为引用的内容: <?
 $GLOBALS['var1'] = 5;
 $var2 = 1;
 function get_value(){
 global $var2;
 $var1 = 0;
 return $var2++;
 }
 get_value();
 echo $var1;
 echo $var2;
 ?>
 |  
 6. 写出如下程序的输出结果
 
    
        
            | 以下为引用的内容: phperz~com <?
 function get_arr($arr){
 unset($arr[0]);
 }
 $arr1 = array(1, 2);
 $arr2 = array(1, 2);
 get_arr(&$arr1);
 get_arr($arr2);
 echo count($arr1);
 echo count($arr2);
 ?>
 |  
 www~phperz~com 7. 使用五种以上方式获取一个文件的扩展名要求:dir/upload.image.jpg,找出 .jpg 或者 jpg ,
 必须使用PHP自带的处理函数进行处理,方法不能明显重复,可以封装成函数,比如 get_ext1($file_name), get_ext2($file_name)
 
 二、算法题 phperz~com
 1. 使用PHP描述冒泡排序和快速排序算法,对象可以是一个数组 phperz~com  2. 使用PHP描述顺序查找和二分查找(也叫做折半查找)算法,顺序查找必须考虑效率,对象可以是一个有序数组3. 写一个二维数组排序算法函数,能够具有通用性,可以调用php内置函数
 
 php程序员站 【附答案】(以下答案不一定是最好的,只是一个简单的参考)一、基础题
 1. 相等相等不相等
 2. true true true true true false true false
 3. aaaaaa
 4. 5 0 1
 5. 5 2
 6. 1 2
 7. 使用五种以上方式获取一个文件的扩展名
 
    
        
            | 以下为引用的内容: function get_ext1($file_name){
 return strrchr($file_name, '.');
 }
 function get_ext2($file_name){
 return substr($file_name, strrpos($file_name, '.'));
 }
 function get_ext3($file_name){
 return array_pop(explode('.', $file_name));
 }
 function get_ext4($file_name){
 $p = pathinfo($file_name);
 return $p['extension'];
 php程序员之家 }
 function get_ext5($file_name){
 return strrev(substr(strrev($file_name), 0, strpos(strrev($file_name), '.')));
 }
 |  
 |