PHP interview questions, with my answers and analysis (1)

Source: Internet
Author: User
Tags echo date

Interview question 1
1. Use PHP to print the time format of the previous day in the format of 22:21:21
2. Differences between echo (), print (), and print_r ()
3. templates that can be used to split HTML and PHP
4. How to Implement PHP and JSP interaction?
5. What tools are used for version control?
6. How to Implement string flip?
7. Optimize the MYSQL database.
8. Talk about Transaction Processing
9. How to achieve maximum load using apache + mysql + php
10. The method for intercepting Chinese strings without garbled characters is implemented.

Answer:

1. echo date ('Y-m-d H: I: s', strtotime ('-1 Day '));

2. echo is a language structure and has no return value. The print function is basically the same as echo. The difference is that print is a function and has a return value. print_r is recursive printing and used to output array objects.

3. so much, in fact, PHP itself is a template engine, I used smarty, common also PHPLib, FastTemplate, Savant here has a template engine list: http://www.sitepoint.com/forums/showthread.php? T = 123769

4. the question is a bit vague. SOAP, XML_RPC, Socket function, and CURL can all achieve this. If PHP and Java are integrated, PHP has built-in this mechanism (If PHP and. NET integration. For example, $ foo = new Java ('java. lang. system ');

5. CVS and SVN. SVN is known as the next generation of CVS and has powerful functions. However, CVS is a veteran with a high market share. I have been using SVN for a long time. The question is what tools are used. Well, this may require the following answers: CVS Server on Apache as the Server, WinCVS as the client, and Subversion on Apache/DAV as the Server, tortoiseSVN is used as the client, or Subclipse is used as the client.

6. Use the strrev function. If you are not allowed to use the built-in PHP function, write it yourself:
Function strrev ($ str)
{
$ Len = strlen ($ str );
$ Newstr = '';
For ($ I = $ len; $ I >=0; $ I --)
{
$ Newstr. = $ str {$ I };
}
Return $ newstr;
}

7. For political questions of the college entrance examination, write down all the knowledge points you know. My answer:
(1 ). in terms of database design, this is the responsibility of DBA and impact ect. A database with a good design structure should be de-normalized when necessary (I don't know what the Chinese translation is ), some data redundancy is allowed to avoid JOIN operations to improve query efficiency.
(2 ). in terms of system architecture design, the table is hashed, and massive data is hashed into several different tables. fast and slow tables: only the latest data is retained. Slow tables are archived in history. cluster, Master server Read & write, slave server read only, or N servers, each machine is a Master
(3). (1) and (2) better than PHP Programmer's requirements. It doesn't matter. check whether there is any less index.
(4 ). write efficient SQL statements to see if there are any inefficient SQL statements, such as generating full connections to cartesian products, a large number of Group By and order by statements, and no limit. when necessary, encapsulate the database logic in the stored procedure of the DBMS. cache query results and explain each SQL statement
(5). All the results are required. Only necessary data is obtained from the database. For example, you can query the number of comments of an article, select count (*)... where article_id =? You can. Do not select *... where article_id =? Then msql_num_rows.
Send only required SQL statements. For example, if you modify only the title when modifying an article, update... set title =? Where article_id =? Do not set content =? (Large text)
(6). Use different storage engines when necessary. For example, InnoDB can reduce deadlocks. HEAP can increase the query speed by an order of magnitude.

8. just as A programming language would have an example that promised Hello World, it would be an example that the textbooks in this database would all talk about A's transfer of $50 to B's account. Just answer this question. as far as I know, MySQL enterprises seldom use MySQL for transaction processing. moreover, Oracle has acquired InnoDB.

9. refer to the answer to question 7. The problem can be solved if the problem is solved.

10. hahaha, I guess the person who asked the question has been troubled by substr's Chinese Character Processing Problem for a long time. Have you still used the functions that are circulated on the Internet to match Chinese characters and then intercept them? In fact, there is a very simple solution: mb_substr ()

Interview question 2
Var $ empty = '';
Var $ null = NULL;
Var $ bool = FALSE;
Var $ notSet;
Var $ array = array ();
1.
$ A = "hello ";
$ B = & $;
Unset ($ B );
$ B = "world ";
What is $?

2.
$ A = 1;
$ X = & $;
$ B = $ a ++;
What is $ B?


3.
$ X = empty ($ array );
What is $ x? True or false


4. Have you used version control software? What is the name of the version control software you use?

5. Have you used the template engine? What is the name of the template engine that you use?

6. Briefly describe your most proud development work.

7. What methods do you use to solve the traffic issue for websites with large traffic volumes?

8. Use PHP to write the code that shows the Client IP address and Server IP Address:

The answer is written again when the blog is updated.

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.