Home  >  Article  >  Backend Development  >  A PHP interview question - said to be from a large company

A PHP interview question - said to be from a large company

WBOY
WBOYOriginal
2016-07-25 08:59:171075browse
  1. $arr1 = array (
  2. '0' => array ('fid' => 1, 'tid' => 1, 'name' =>'Name1' ),
  3. '1' => array ('fid' => 1, 'tid' => 2 , 'name' =>'Name2' ),
  4. '2' => array ('fid' => 1, ' tid' => 5 , 'name' =>'Name3' ),
  5. '3' => array ('fid' => 1, 'tid' => 7 , 'name' =>' Name4' ),
  6. '4' => array ('fid' => 3, 'tid' => 9, 'name' =>'Name5' )
  7. );
  8. $arr2 = array (
  9. ' 0' => array (
  10. '0' => array ( 'tid' => 1, 'name' => 'Name1'),
  11. '1' => array ( 'tid' => 2, 'name' => 'Name2'),
  12. '2' => array ( 'tid' => 5, 'name' => 'Name3'),
  13. '3' => array ( 'tid' => 7, 'name' => 'Name4')
  14. ),
  15. '1' => array (
  16. '0' => array ( 'tid' => 9, 'name' => 'Name5' )
  17. )
  18. );
Copy code

5. Please briefly describe the paradigm and application of database design. Generally, the 3rd normal form is sufficient for optimizing the table structure. This can not only avoid the application being too complex, but also avoid the inefficiency of the system caused by too large SQL statements.

6. There are multiple records of Id in a table. Find out all the records of this id and display the total number of records. Use SQL statements, views, and stored procedures to implement this.

  1. DELIMITER //

  2. CREATE PROCEDURE ProcGet
  3. (
  4. IN ID_a INT(11)
  5. )

  6. BEGIN

  7. DECLARE EXIT HANDLER FOR SQLEXCEP TION BEGIN END;
  8. SELECT COUNT(*) AS Sum FROM News Where ID = ID_a;
  9. END;//

  10. CALL ProcGet(88)//

Copy code

7. There are three columns A, B, and C in the table. Use SQL statements to implement this: when column A is greater than column B, select column A; otherwise, select column B; when column B is greater than column C, select column B; otherwise, select column C.

  1. DELIMITER //

  2. CREATE PROCEDURE ProcOut()
  3. BEGIN
  4. DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
  5. DECLARE Sum_a INT(11);
  6. DECLARE Sum_b INT( 11);
  7. DECLARE Sum_c INT(11);

  8. --Get the total value in column A<--

  9. DECLARE cur_1 CURSOR FOR SELECT SUM(A) FROM table_name;
  10. OPEN cur_1;
  11. FETCH cur_ 1 INTO Sum_a;
  12. CLOSE cur_1;

  13. --Get the total value in column B<--

  14. DECLARE cur_2 CURSOR FOR SELECT SUM(B) FROM table_name;
  15. OPEN cur_2;
  16. FETCH cur_ 2 INTO Sum_b;
  17. CLOSE cur_2;

  18. --Get the total value in column C<--

  19. DECLARE cur_3 CURSOR FOR SELECT SUM(C) FROM table_name;
  20. OPEN cur_3;
  21. FETCH cur_ 3 INTO Sum_c;
  22. CLOSE cur_3;

  23. IF Sum_a > Sum_b THEN

  24. SELECT A FROM table_name;

  25. ELSEIF Sum_b > Sum_c THEN

  26. SELECT B FROM table_name;

  27. ELSE

  28. SELECT C FROM table_name;
  29. END IF;;
  30. END;//

  31. CALL ProcOut()//

Copy code

8. Please briefly describe the method to optimize the execution efficiency of SQL statements in the project. From what aspects, how to analyze the performance of SQL statements? 9. If the template is a smart template. How to use section statement to display an array named $data. for example:

  1. $data = array(
  2. [0] => array( [id]=8 [name]='name1')
  3. [1] => array( [id]=10 [name] ='name2')
  4. [2] => array( [id]=15 [name]='name3')
  5. ......
  6. )
Copy code

Write the code on the template page? How to display it if using foreach statement?

10. Write a function that can traverse all files and subfolders in a folder. (Directory operation)

11, two tables, city table and province table. They are the relationship tables between cities and provinces respectively.

city: id City Provinceid 1 Guangzhou 1 2 Shenzhen 1 3 Huizhou 1 4 Changsha 2 5 Wuhan 3 ………. Guangzhou province: id Province 1 Guangdong 2 Hunan 3 Hubei ……….

(1) Write a SQL statement to relate two tables to achieve: display the basic information of the city. ? (2) Display fields: city id, city name, province. like: Id (city id) Cityname (city name) Privence (province) . . . .

(2) If you want to count how many cities there are in each province, please use group by to query it. ? Display fields: province id, province name, how many cities it contains.

12. Based on your experience, please briefly describe the steps of software development for software engineering. Which of the following tools have you used: Rational Rose, PowerDesigner, Project, VSS or CVS, and TestDirector? What are the disadvantages? 13. Please briefly describe the difference between threads and processes in the operating system. List the software you have used under LINUX? 14. Please use pseudo language combined with data structure bubble sorting method to sort the following set of data 10 2 36 14 10 25 23 85 99 45.



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