Php interview question 4 1. connection and difference between cookies and Sessions. how can multiple web servers share sessions?
2. what is the difference between POST and GET in HTTP?
3. a piece of php code, writing output results, is not difficult, but sets a small trap.
4. reqiure's include can contain files. What are the differences between the two?
(At this point, I have done a good job and it will be miserable)
5. what is the principle of WEB file upload in php? how can I limit the size of uploaded files?
6. write a function to traverse all the files and folders in the folder.
7. 8. There are several unix shell questions in the middle (as if they were two), because I don't understand them and I don't remember these questions.
9. a document with mail. log contains several email addresses separated by '\ n. Select xxx.com email addresses (including reading, filtering, and printing files ).
1) Which statement shows the maximum salary paid in each job category of each department? _______
A. select dept_id, job_cat, max (salary) from employees where salary> max (salary );
B. select dept_id, job_cat, max (salary) from employees group by dept_id, job_cat;
C. select dept_id, job_cat, max (salary) from employees;
D. select dept_id, job_cat, max (salary) from employees group by dept_id;
E. select dept_id, job_cat, max (salary) from employees group by dept_id, job_cat, salary;
2) description of the students table:
Sid_id number
Start_date date
End_date date
Which two function are valid on the start_date column? _________.
A. sum (start_date)
B. avg (start_date)
C. count (start_date)
D. avg (start_date, end_date)
E. min (start_date)
F. maximum (start_date)
3) for which two constraints does the oracle server implicitly create a unique index? ______.
A. not null
B. primary
C. foreign key
D. check
E. unique
4) in a select statement that includes des a where clause, where is the group by clause placed in the select statement? ______.
A. immediately after the select clause
B. before the where clause
C. before the from clause
D. after the order by clause
E. after the where clause
5) in a select statement that includes des a where clause, where is the order by clause placed in the select statement? ______.
A. immediately after the select clause
B. before the where clause
C. after all clause
D. after the where clause
E. before the from clause
6) evaluate there two SQL statements ______.
Select last_name, salary from employees order by salary;
Select last_name, salary from employees order by 2 asc;
A. the same result B. different result C. the second statement returns a syntax error
7) you wowould like to display the system date in the format "20051110 14:44:17 ". Which select statement shocould you use? ______.
A. select to_date (sydate, 'yearmmdd hh: mm: SS') from dual;
B. select to_char (sydate, 'earmonthday hh: mi: SS') from dual;
C. select to_date (sydate, 'yyyymmdd hh24: mi: SS') from dual;
D. select to_char (sydate, 'yyyymmdd hh24: mi: SS') from dual;
E. select to_char (sydate, 'YY-mm-dd hh24: mi: SS') from dual;
8) which select statement will the result 'ello world' from the string 'Hello World '? ______.
A. select substr ('Hello World', 1) from dual;
B. select substr (trim ('Hello World', 1,1) from dual;
C. select lower (substr ('Hello World', 1) from dual;
D. select lower (trim ('h' from 'Hello World') from dual;
9) which are DML statements (choose all that apply )______.
A. commit B. merge C. update D. delete E. creat F. drop
10) in the Select statement, the character used to connect strings is ______.
DA. "+" B. "&" C. "|" D. "|"
Q: What is a clustered index, what is a non-clustered index, and what is a primary key?
1. how can I use the php environment variable to get the content of a webpage address? How can I get the IP address?
[Php]
Echo $ _ SERVER ['php _ SELF '];
Echo $ _ SERVER ['server _ ADDR '];
[/Php]
2. calculate the difference between two dates, for example, 2007-2-5 ~ Date difference of-3-6
[Php]
$ Begin = strtotime ('2014-2-5 ');
$ End = strtotime ('2017-3-6 ');
Echo ($ end-$ begin)/(24*3600 );
[/Php]
3. write a function to implement the following functions:
Convert the string "open_door" to "OpenDoor" and "make_by_id" to "MakeById ".
[Php]
Function changeStyle (& $ str ){
/* $ Str = str_replace ("_", "", $ str );
$ Str = ucwords ($ str );
$ Str = str_replace ("", "", $ str );
Return $ str ;*/
$ ArrStr = explode ('_', $ str );
Foreach ($ arrStr as $ key => $ value ){
$ ArrStr [$ key] = strtoupper (substr ($ value, 0, 1). substr ($ value, 1 );
}
Return implode ('', $ arrStr );
}
$ S = "open_door ";
Echo changeStyle ($ s );
[/Php]
4. write a program to convert the following array $ arr1 into an array $ arr2:
[Php] $ 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 ')
)
);
$ 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 ')
);
Function changeArrayStyle ($ arr ){
Foreach ($ arr as $ key => $ value ){
$ Result [$ value ['fid'] [] = $ value;
}
Return array_values ($ result );
}
$ Arr2 = changeArrayStyle ($ arr1 );
Echo"
";
Var_dump ($ arr2 );
[/Php]
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.
ANSWER:
First paradigm: if every attribute of the relational model R cannot be decomposed, then it belongs to the first paradigm.
Second paradigm: if R belongs to the first paradigm, and all non-code attributes depend entirely on the code attributes, the second paradigm is used.
Third paradigm: if R belongs to the second paradigm, and none of all non-code attributes depend on candidate codes, then it belongs to the third paradigm.
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.
Stored Procedure:
[Php]
DELIMITER //
Create procedure proc_countNum (in columnId int, out rowsNo int)
Begin
Select count (*) into rowsNo from member where member_id = columnId;
End
Call proc_countNum (1, @ no );
Select @ no;
[/Php]
View:
Create view v_countNum as select member_id, count (*) as countNum from member group by member_id
Select countNum from v_countNum where member_id = 1
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.
[Php] select
Case
When first_name> middle_name then
Case when first_name> last_name then first_name
Else last_name end
Else
Case when middle_name> last_name then middle_name else last_name
End
End as name
From member
[/Php]
8. briefly describe how to optimize the SQL statement execution efficiency in the project. In what ways can we analyze the SQL statement performance?
ANSWER: SQL optimization is useful, so it is better to add indexes directly.
9. if the template is a smarty template. How to use the section Statement to display an array named $ data. For example:
[Php] $ data = array (
[0] => array ([id] = 8 [name] = 'name1 ′)
[1] => array ([id] = 10 [name] = 'name2 ′)
[2] => array ([id] = 15 [name] = 'name3 ′)
......
) [/Php]
Write the code on the template page? How can I display it with the foreach statement?
Accounts for no answer.
10. write a function to traverse all files and subfolders in a folder. (Directory Operations)
[Php]
$ D = dir (dirname (_ file __));
// Echo "Handle:". $ d-> handle. "\ n ";
// Echo "Path:". $ d-> path. "\ n ";
While (false! ==( $ Entry = $ d-> read ())){
Echo $ entry ."
";
}
$ D-> close ();
[/Php]
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
..........
(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.
ANSWER:
1. select A. id, A. Cityname, B. Province from city A, province B where A. provinceid = B. id
2. select B. id, B. Province, count (*) as num from city A, province B where A. provinceid = B. id group by B. id
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?
The company uses dbdesigner and cvs, and the test management tool uses Mantis.
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.
[Php] function bubble_sort (& $ arr ){
$ Number = count ($ arr );
For ($ I = 0; $ I <$ number-1; $ I ++ ){
For ($ j = 0; $ j <$ number-1-$ I; $ j ++ ){
If ($ arr [$ j]> $ arr [$ j + 1]) {
$ Tmp = $ arr [$ j];
$ Arr [$ j] = $ arr [$ j + 1];
$ Arr [$ j + 1] = $ tmp;
}
}
}
}
$ Str = "10 2 36 14 10 25 23 85 99 45 ";
$ Arr = explode ("", $ str );
Bubble_sort ($ arr );
Echo"";
Var_dump ($ arr );
[/Php] 6. write the names of more than three MySQL database storage engines (note: case insensitive)
Dozens of engines including MyISAM, InnoDB, BDB (Berkeley DB), Merge, Memory (Heap), Example, Federated, Archive, CSV, Blackhole, and MaxDB
7. name the three or more open source databases you know (tip: think about the popular open source databases outside China)
MySQL, SQLite, BDB (Berkeley DB), PostgreSQL, Firebird
8. What are the main differences between the field types varchar and char in the MySQL database? The field search efficiency is high. why?
Varchar is longer, saving storage space, and char is a fixed length. The query efficiency is faster than that of the char type. because varchar is not a fixed length, you must first search for the length and then extract the data. this is more efficient than the char fixed length type.
9. tell us the two major differences between MySQL 4.0 and MySQL 4.1. If you have used MySQL 5, tell us the main differences between MySQL 5 and MySQL 4. (Selected in the second half)
MySQL 4.1 features subqueries and character encoding more than MySQL 4.0.
MySQL5 has more features than MySQL4, including stored procedures, views, transactions, and so on.
10. What are the three basic optimization rules for MySQL databases, except for increasing hardware and bandwidth? (Tip: service configuration, application, and development considerations)
(1) system service optimization: increase the capacity of MySQL's key_buffer, cache_buffer, and query_cache.
(2) add an appropriate index for all frequently queried fields
(3) optimize SQL statements to reduce operations on Ditinct, Group, Join, and other statements