Php interview knowledge

Source: Internet
Author: User
Php interview knowledge started to engage in php again, and a lot of php knowledge was forgotten. the way to learn php is to read the interview questions.

Below is a php interview question I collected

1. use PHP to print the time format of the previous day in the format of 22:21:21 (2 points)
Echo date ("Y-m-d H: I: s", strtotime ("-1 day "));
2. differences between echo (), print (), and print_r () (3 points)
Echo is a PHP statement that can output one or more strings. The echo efficiency is relatively high and there is no return value.
Print and print_r are functions with returned values.
Print can only print simple type variables (such as int and string), and can only output one string at a time.
Print_r can print complex type variables (such as arrays and objects)

3. templates that can separate HTML and PHP (1 point)
TemplateLib, smarty ,.....

4. what tools are used for version control? (1 point)
Typical examples: CVS and Subversion

5. how to implement string flip? (3 points)
You can use the strrev function of PHP to flip strings directly or write the following code by yourself:
$ Str = "hello, World! ";
For ($ I = strlen ($ str)-1; $ I >=0; $ I --){
Echo $ str [$ I];
}
Echo "\ n ";
6. optimize the MYSQL database. (4 points, more writes)
Create indexes and optimize the database table structure
Use Stored procedures;

7. PHP meaning (1 minute)
PHP: Hypertext Preprocessor, short for Hypertext Preprocessor

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

9. the method of intercepting Chinese strings without garbled characters is implemented. (3 points)
Function mysubstr ($ str, $ start, $ len ){
$ Tmpstr = "";
$ Strlen = $ len + $ start;
For ($ I = $ start; $ I <$ strlen; $ I ++ ){
If (ord (substr ($ str, $ I, 1)> 0xa0 ){
$ Tmpstr. = substr ($ str, $ I, 2 );
$ I ++;
}
Else {
$ Tmpstr. = substr ($ str, $ I, 1 );
}
}
Return $ tmpstr;
}
The following four questions are their respective usage. I will not answer them here (I am not sure about some of them ).
10. have you used version control software? What is the name of the version control software you use? (1 point)
11. have you used the template engine? What is the name of the template engine that you use? (1 point)
12. Briefly describe your most proud development work (4 points)
13. What methods do you use to solve the traffic issue for high-traffic websites? (4 points)

14. use PHP to write the code for displaying the client IP address and server IP Address: 1 point)
$ Server = getenv ("SERVER_ADDR ");
$ Server_ip = getenv ("SERVER_ADDR ");
$ Client_ip = $ _ SERVER ['remote _ ADDR '];
$ Client_ip = getenv ("HTTP_X_FORWARDED_FOR ");
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)
Include is located in the processing part of the program flow control. it is read only when the program executes include.
Require is generally at the beginning of the program. before execution, the php program will first read the files contained in require () to make it part of the php program.
Use include_once () and require_once () instead.

16. how to modify the SESSION survival time (1 point ).
$ LifeTime = 24*3600;
Session_set_cookie_params ($ lifeTime );
Sorry, I changed it to my homepage.
17. there is a webpage address, such as the hongxincao blog homepage: http://www.hongxincao.com/. how can I find my website content? ($1)
$ Content = file_get_contents ("http://www.hongxincao.com");
Echo $ content;

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)
Header ("HTTP/1.0 401 Authorization Required ");

Other php-related interview questions

Http://dason.blog.51cto.com/658897/498831

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.