Home Backend Development PHP Tutorial PHP2017 latest version interview questions (with answers)

PHP2017 latest version interview questions (with answers)

Nov 18, 2017 pm 04:55 PM
php new version

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="#"

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles