Home  >  Article  >  Backend Development  >  Several written test questions and answers for PHP programmer interview questions

Several written test questions and answers for PHP programmer interview questions

WBOY
WBOYOriginal
2016-07-25 08:59:231117browse
  1. $str1 = null;
  2. $str2 = false;
  3. echo $str1==$str2 ? 'Equal' : 'Not equal';
  4. $str3 = ”;
  5. $str4 = 0;
  6. echo $str3==$str4 ? 'Equal' : 'Not equal';
  7. $str5 = 0;
  8. $str6 = '0′;
  9. echo $str5===$str6 ? 'Equal' : 'Not equal' ;
  10. ?>
Copy the code

2. Write the output of the following program

  1. $a1 = null;
  2. $a2 = false;
  3. $a3 = 0;
  4. $a4 = ”;
  5. $a5 = '0′;
  6. $a6 = 'null';
  7. $a7 = array();
  8. $a8 = array(array());
  9. echo empty($a1) ? 'true' : 'false';
  10. echo empty($a2) ? 'true' : 'false';
  11. echo empty($a3) ? 'true' : 'false';
  12. echo empty($a4) ? 'true' : 'false';
  13. echo empty($a5) ? 'true' : 'false';
  14. echo empty($a6) ? 'true' : 'false';
  15. echo empty($a7) ? 'true' : 'false';
  16. echo empty($a8) ? 'true' : 'false';
  17. ?>
Copy the code

3. Write the output of the following program

  1. $test = 'aaaaaa';
  2. $abc = & $test;
  3. unset($test);
  4. echo $abc;
  5. ?>
Copy code

4 .Write the output of the following program

  1. function get_count(){
  2. static $count = 0;
  3. return $count++;
  4. }
  5. echo $count;
  6. ++$count;
  7. echo get_count() ;
  8. echo get_count();
  9. ?>
Copy the code

5. Write the output of the following program

  1. $GLOBALS['var1'] = 5;
  2. $var2 = 1;
  3. function get_value(){
  4. global $var2;
  5. $var1 = 0;
  6. return $var2++;
  7. }
  8. get_value();
  9. echo $var1;
  10. echo $var2;
  11. ?>
Copy code

6. Write the output of the following program

  1. function get_arr($arr){
  2. unset($arr[0]);
  3. }
  4. $arr1 = array(1, 2);
  5. $arr2 = array(1, 2) ;
  6. get_arr(&$arr1);
  7. get_arr($arr2);
  8. echo count($arr1);
  9. echo count($arr2);
  10. ?>
Copy code

7. Use more than five kinds How to get the extension of a file Required: dir/upload.image.jpg, find .jpg or jpg, It must be processed using the processing functions that come with PHP. The methods cannot be obviously repeated and can be encapsulated into functions, such as get_ext1($file_name), get_ext2($file_name)

2. Algorithm questions

1. Use PHP to describe bubble sort and quick sort algorithms. The object can be an array

2. Use PHP to describe sequential search and binary search (also called binary search) algorithms. Sequential search must consider efficiency, and the object can be an ordered array

3. Write a two-dimensional array sorting algorithm function that is versatile and can call PHP built-in functions

#-------------------------- (The following answer is not necessarily the best, just a simple reference) 1 2 Next page Last page



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