PHP2017 latest version interview questions (with answers)

php中世界最好的语言
Release: 2023-03-17 15:56:02
Original
1654 people have browsed it

Seeing that many friends are asking for PHP interview questions, I collected some interview questions for you. These are all the latest questions in 2017. I hope they will help you improve your skills. I also wish you can get into the company you want to work in.

This article collects and analyzes the latest 2017 PHP interview questions in more detail. Share it with everyone for your reference. The details are as follows:


1. Use PHP to print out the time of the previous day in the format of 2006-5-10 22:21:21 (2 minutes)

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

print_r($a);

2, echo The difference between (), print() and print_r() (3 points)

echo and print are not a function, but a language structure

int print(string $arg), only one parameter

echo arg1,arg2; can output multiple parameters and return void

echo and print can only print out string, not the structure

print_r can print out 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 achieve string flipping?(3 points)

English :

strrev($a)

Chinese or other text:

Chinese: GB2312, the code is encoded using GB2312

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. Methods to optimize MYSQL database. (4 points, write more and get more)

Statement aspects:

1 Use index to increase query efficiency

2 Optimize query statements and improve index hit rate

Aspects involved in the database:

1 Construct sub-databases and tables to improve the storage and expansion capabilities of the database

2 Use different storage engines as needed


7. The meaning of PHP (send 1 point)

Hypertext Preprocessing Language

Hypertext PreProcessor


8 , What is the function for MYSQL to obtain the current time?, and the function for formatting the date is (2 points)

CURRENT_TIMESTAMP()

DATE_FORMAT()

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

9. Method to intercept Chinese text strings without garbled characters. (3 points)

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

10. Have you ever used version control software? If so, have you used it? What is the name of the version control software? (1 point)

svn

git


11. Have you ever used a template engine? If there is a template engine you use, what is the name? (1 point)

smarty


12. Please briefly describe your most proud development work ( 4 points)

XXX


13. For websites with large traffic, what method do you use to solve the traffic problem? (4 points)

1 Effectively use cache to increase cache hit rate

2 Use load balancing

3 Use CDN to store and accelerate static files

4 Ideas to reduce database Use

5 Check where the bottleneck of statistics is


14. Use PHP to write the code to display the client IP and server IP 1 point)

$_SERVER["REMOTE_ADDR"]

$_SERVER["SERVER_ADDR"]


15. What is the difference between the statement include and require ?To avoid including the same file multiple times, you can use (?) statements to replace them? (2 points)

When it fails:

include generates a warning, while require generates a direct error interrupt

require is loaded before running

include is loaded at runtime

require_once

include_once


16. How to modify the survival time of SESSION (1 minute).

session_set_cookie_params


17. There is a web page address, such as the homepage of the PHP Research Laboratory : http://www.jb51.net/index.html, how to get its content? ($1 point)

file_get_contents

curl


18. In HTTP 1.0, the meaning of status code 401 is (?); if the prompt "File not found" is returned, the header function can be used, and its 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 = <

good test

EOD;

20. Talk about asp , Advantages and disadvantages of php and jsp (1 point)

asp needs to rely on IIS and is a language developed by Microsoft

php and jsp can rely on other servers such as apache or nginx


21. Talk about your understanding of mvc (1 point)

model: data structure layer

view: display

control: Receive and judge the input


#22. Write the SQL of the names of the ten people with the most posts. Use the following table: members(id,username,posts,pass,email )(2 minutes)

select top 10 id,username from members order by posts desc


23. Please explain the difference between passing values ​​and passing references in PHP. When to pass by value and when to pass by reference? (2 points)

& means passing by reference

Passing the parameter by reference in the function will change the parameter

Generally in the output parameter When there are more than one, you can consider using references


24. What is the function of error_reporting in PHP? (1 point)

Set the display level of error


25. Please write a function to verify whether the format of the email 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 get the current execution script path, including the obtained parameters . (2 points)

$argc --Get the number of parameters

$argv --Get the parameter list


27. How to modify SESSION The survival time. (1 point)

session_set_cookie_params


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

alert()

confirm()

promote()

focus()


29. What is the redirection function of JS? How to introduce an external JS file? (2 points)

window.location.href="#"

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!