PHP classic interview questions

Source: Internet
Author: User
This article mainly introduces the collection of typical PHP interview questions and collects common php interview questions and related reference answers for your reference, for more information, see this article. Share it with you for your reference. The details are as follows:

I did some php questions on the Internet, but I don't know how to do it now... I posted the answer for your reference.

1. use PHP to print the time format of the previous day in the format of 22:21:21 (2 points)

$a = date("Y-m-d H:i:s", strtotime("-1 day"));print_r($a);

2. differences between echo (), print (), and print_r () (3 points)
Echo and print are not a function, but a language structure.
Int print (string $ arg), with only one parameter
Echo arg1, arg2; multiple parameters can be output and void is returned.
Echo and print can only print the string, but cannot print the structure
Print_r can print the structure
For example

$arr = array("key"=>"value");print_r($arr);

3. templates that can separate HTML and PHP (1 point)
Smarty, phplib

4. what tools are used for version control? (1 point)
Svn, git, cvs

5. how to implement string flip? (3 points)
English:
Strrev ($)
Chinese or other words:
Chinese: GB2312. The code uses GB2312 encoding.

<? Php function reverse ($ str) {$ ret = ""; len = mbstrwidth (str, "GB2312"); for (I = 0; I <len; I ++) {arr [] = mbsubstr (str, $ I, 1, "GB2312");} return implode ("", array_reverse ($ arr ));} print_r (reverse ("Hello "));

6. optimize the MYSQL database. (4 points, more writes)
Statement:
1. use indexes to increase query efficiency
2. optimize query statements to improve index hit rate
Database:
1. construct database/table sharding to improve database storage and scalability
2. use different storage engines as needed

7. PHP meaning (1 minute)
Super Text preprocessing language
Hypertext PreProcessor

8. what is the function for MYSQL to obtain the current time ?, The format function is (2 points)

CURRENT_TIMESTAMP()DATE_FORMAT()select DATE_FORMAT("2011-11-21 10:10:10", "%Y-%m-%d");

9. the method of intercepting Chinese strings without garbled characters is implemented. (3 points)

mb_substr($str, 1, 1, "GB2312");

10. have you used version control software? What is the name of the version control software you use? (1 point)
Svn
Git

11. have you used the template engine? What is the name of the template engine that you use? (1 point)
Smarty

12. Briefly describe your most proud development work (4 points)
XXX

13. What methods do you use to solve the traffic issue for high-traffic websites? (4 points)
1. effectively use the cache to increase the cache hit rate
2. use server load balancer
3. use CDN to store and accelerate static files
4. reduce database usage
5. check where the statistical bottleneck is.

14. use PHP to write the code for displaying the client IP address and server IP Address: 1 point)
$ _ SERVER ["REMOTE_ADDR"]
$ _ SERVER ["SERVER_ADDR"]

15. what is the difference between the include statement and require statement? To avoid multiple accesses to the same file (?) Statement instead of them? (2 points)
In case of failure:
Include generates a warning, while require directly produces an error interrupt.
Require load before running
Include load at runtime
Require_once
Include_once

16. how to modify the SESSION survival time (1 point ).
Session_set_cookie_params

17. there is a webpage address, such as the homepage of the PHP Research Office: http://www.bitscn.com/index.html. how can I find my website content? ($1)
File_get_contents
Curl

18. in HTTP 1.0, status code 401 indicates (?); If the message "File Not Found" is returned, the header function is available. The statement is (?); (2 points)
Unauthorized

header("HTTP/1.0 404 Not Found");

Fast CGI:

header("Status: 404 Not Found");

19. in PHP, heredoc is a special string and its end mark must be? (1 point)
Appear in pairs

$ A = <
 
  

20. Advantages and disadvantages of asp, php, and jsp (1 point)
Asp depends on IIS and is a language developed by Microsoft.
Php and jsp can depend on apache, nginx, and other servers.

21. about mvc (1 point)
Model: data structure layer
View: Display
Control: receives and judges the processing input.

22. write the SQL statement for the top 10 people with the most posts. use the following table: members (id, username, posts, pass, email) (2 points)
Select top 10 id, username from members order by posts desc

23. The difference between passing a value in php and transferring a reference. When will the value be passed for reference? (2 points)
& Indicates transferring reference
The parameter will be changed when the parameter is passed for reference in the function.
Generally, when multiple output parameters exist, you can consider using references.

24. what is the role of error_reporting in PHP? (1 point)
Set the display level of the error

25. please write a function to verify that the email format is correct (2 points)

$ Str = "jianfeng@126.com"; regex = "([a −z0 −9 \. −] +) @ ([\ da −z \. −] + )\. ([a −z \.] 2, 6) "; // regular return preg_match (regex, str)

26. briefly describe how to obtain the path of the script to be executed, including the obtained parameters. (2 points)
$ Argc -- get the number of parameters
$ Argv -- get the parameter list

27. how to modify the SESSION survival time (1 point)
Session_set_cookie_params

28. what is the function in the JS form pop-up dialog box? What is the input focus function? (2 points)

Alert ()
Confirm ()
Promopt ()
Focus ()

29. what is the JS steering function? How to introduce an external JS file? (2 points)

Window. location. href = "#"

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.