A set of PHP interview questions

Source: Internet
Author: User
Use groupby to query the number of cities in each province.

1. how can I use the php environment variable to get the content of a webpage address? How can I get the IP address?

Answer: "http: //". $ _ SERVER ['http _ host']. $ _ SERVER ['php _ SELF '] // Obtain the webpage address

$ _ SERVER ['remote _ ADDR '] // obtain the IP address

2. calculate the difference between two dates, for example, 2007-2-5 ~ Date difference of-3-6
$ From = mktime );
$ To = mktime );
Echo ($ to-$ from)/(3600*24 );

3. write a function to implement the following functions:
Convert the string "open_door" to "OpenDoor" and "make_by_id" to "MakeById ".
Answer: $ function strOpt ($ str ){
$ Str_arr = explode ("_", $ str );
$ Len = count ($ str_arr );
$ NewStr = "";
$ Str_arr = array_reverse ($ str_arr );
For ($ I = 0; $ I <$ len; $ I ++ ){
$ NewStr = ucfirst ($ str_arr [$ I]). $ newStr;
}
Return $ newStr;
}

Echo strOpt ("make_by_id ");

 

4. write a program to convert the following array $ arr1 into an array $ arr2:
$ Arr1 = array (

'0' => array ('fid' => 1, 'tid' => 1, 'name' => 'name1 ′),

'1' => array ('fid' => 1, 'tid' => 2, 'name' => 'name2 ′),

'2' => array ('fid' => 1, 'tid' => 5, 'name' => 'name3 ′),

'3' => array ('fid' => 1, 'tid' => 7, 'name' => 'name4 ′),

'4' => array ('fid' => 3, 'tid' => 9, 'name' => 'name5 ′)

);
$ Arr2 = array (

'0' => array (

'0' => array ('tid' => 1, 'name' => 'name1 ′),

'1' => array ('tid' => 2, 'name' => 'name2 ′),

'2' => array ('tid' => 5, 'name' => 'name3 ′),

'3' => array ('tid' => 7, 'name' => 'name4 ′)

),

'1' => array (

'0' => array ('tid' => 9, 'name' => 'name5 ′)

)

);

 

5. briefly describe the database design paradigm and application.

Generally, the 3rd paradigm is enough to optimize the table structure. This can avoid the complexity of applications and the low system efficiency caused by too large SQL statements.

6. the Id in a table has multiple records. check all records of this id and display the total number of records. these records are implemented using SQL statements, views, and stored procedures.

DELIMITER //

Create procedure ProcGet

(
IN ID_a INT (11)
)

BEGIN

Declare exit handler for sqlexception begin end;

Select count (*) AS Sum FROM News Where ID = ID_a;

END ;//

CALL ProcGet (88 )//

7. The table contains three columns A, B, and C, which are implemented using SQL statements: Select Column A if Column A is greater than Column B; otherwise, select column B, if Column B is greater than column C, column B is selected; otherwise, column C is selected.

DELIMITER //

Create procedure ProcOut ()

BEGIN

Declare exit handler for sqlexception begin end;

DECLARE Sum_a INT (11 );

DECLARE Sum_ B INT (11 );

DECLARE Sum_c INT (11 );

-Obtain the total value of column A <-

DECLARE cur_1 cursor for select sum (A) FROM table_name;

OPEN cur_1;

FETCH cur _ 1 INTO Sum_a;

CLOSE cur_1;

-Obtain the total value of column B <-

DECLARE cur_2 cursor for select sum (B) FROM table_name;

OPEN cur_2;

FETCH cur _ 2 INTO Sum_ B;

CLOSE cur_2;

-Obtain the total value in column C <-

DECLARE cur_3 cursor for select sum (C) FROM table_name;

OPEN cur_3;

FETCH cur _ 3 INTO Sum_c;

CLOSE cur_3;

IF Sum_a> Sum_ B THEN

Select a from table_name;

ELSEIF Sum_ B> Sum_c THEN

Select B FROM table_name;

ELSE

Select c from table_name;

End if ;;

END ;//

CALL ProcOut ()//

8. briefly describe how to optimize the SQL statement execution efficiency in the project. In what ways can we analyze the SQL statement performance?

9 If the template is a smarty template. How to use the section Statement to display an array named $ data. For example:

$ Data = array (

[0] => array ([id] = 8 [name] = 'name1 ′)

[1] => array ([id] = 10 [name] = 'name2 ′)

[2] => array ([id] = 15 [name] = 'name3 ′)

......

)

Write the code on the template page? How can I display it with the foreach statement?

10. write a function to traverse all files and subfolders in a folder. (Directory Operations)

11. two city and province tables. These are the relationship tables between cities and provinces.

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 province

..........

 

(1) Write an SQL statement to link two tables. implementation: display the basic information of the city .?

(2) display field: City id, city name, and province.

For example:

Id (City id)

Cityname (city name)

Privence (province)

.........

 

 

.........

 

 

 

 

 

(2) If you want to count the number of cities in each province, use group by to query them .?

Display field: province id, province name, and number of cities.

12. based on your experience, briefly describe the steps for software development in software engineering. What are the disadvantages of the following tools used by Rational Rose, PowerDesigner, Project, VSS, CVS, and TestDirector?

13. briefly describe the differences between the operating system threads and processes. List the software you have used in LINUX?

14. Use a pseudo-language combined with the data structure bubble sorting method to sort the following groups of data 10 2 36 14 10 25 23 85 99 45.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.