Home  >  Article  >  Backend Development  >  The most comprehensive summary of PHP interview questions and answers in 2017

The most comprehensive summary of PHP interview questions and answers in 2017

黄舟
黄舟Original
2018-05-14 14:14:3415619browse

Recently, I have seen many friends on the Internet asking how to deal with PHP interviews. This is no problem for friends with work experience and practical projects, but for friends who have just learned PHP, PHP interview is a very important step, so today PHP Chinese website will give you a summary of PHP interview questions, many of which are encountered by many programmers during interviews! Hope it helps you!

Part 1: Basic PHP interview questions

1. A major of PHP language The advantage is cross-platform. What is cross-platform?

The optimal combination of PHP's operating environment is Apache+MySQL+PHP. This operating environment can be configured on different operating systems (such as windows, Linux, etc.) and is not subject to manipulation. System limitations, so it’s called cross-platform

2. Tell me what web front-end technologies you have mastered?

Proficient in DIV+CSS web page layout, JavaScript, jQuery framework, photoshop image processing

3. Program now MVC three-layer structure is often adopted in the Internet. Which three layers does MVC refer to and what are its advantages?

The three layers of MVC refer to: business model, view, and controller. The controller layer calls the model to process the data, and then maps the data to the view layer for display. , the advantages are: ① It can achieve code reusability and avoid code redundancy; ② M and V realize code separation, so that the same program can use different expressions

4. Understanding of json data format?

JSON (JavaScript Object Notation) is a lightweight data exchange format. The json data format is fixed and can be used in a variety of ways. Language is used to transfer data

The function in PHP that handles json format is json_decode(string $json [, bool $assoc]), which accepts a JSON format string and converts it into a PHP variable, parameter json A string in json string format to be decoded. assoc When this parameter is TRUE, it will return array instead of object;

Json_encode: Convert PHP variables into json format

5. What are the advantages of AJAX?

ajax is an asynchronous transmission technology that can be implemented through javascript or the JQuery framework to achieve partial refresh, which reduces the pressure on the server and improves user experience. Experience

#6. In the development of the program, how to improve the operating efficiency of the program?

① Optimize SQL statements, try not to use select * in query statements, use which field to check which field; use less subqueries and can be replaced by table connections; use less Fuzzy query;

②Create an index in the data table;

③In the program Generate cache for frequently used data;

##7.PHP Commonly used functions for processing arrays? (Focus on the 'parameters' and 'return value' of the function)

①array() creates an array;

②count() Returns the number of elements in the array;

③array_push() inserts one or more elements into the end of the array (push);

④array_column () Returns the value of a single column in the input array;

array_combine() Creates a new array by merging two arrays;

array_reverse() Returns the array in reverse order;

⑦array_unique() deletes duplicate values ​​in the array;

⑧in_array() checks whether the specified value exists in the array;

8. Commonly used functions for PHP to process strings?

①trim() removes blank characters and other characters on both sides of the string;

substr_replace() Replace part of the string with another string;

③substr_count() Count the number of times a substring appears in the string;

④substr() returns a part of the string;

⑤strtolower() converts the string to lowercase letters;

⑥strtoupper() Convert the string to uppercase letters;

⑦strtr() converts specific characters in the string;

⑧strrchr() finds the string in The last occurrence of a string in another string;

⑨strstr() finds the first occurrence of a string in another string (case-sensitive); strrev() reverses String; strlen() returns the length of the string; str_replace() replaces some characters in the string (case sensitive); print() outputs one or more strings; explode() breaks the string into an array ; is_string() detects whether the variable is a string; strip_tags() removes HTML tags from a string; mb_substr() is used to intercept Chinese and English functions

Part 2: Database part of PHP interview questions

#1. What are the common relational database management system products?

Answer: Oracle, SQL Server, MySQL, Sybase, DB2, Access, etc.

2. What is a transaction? and its characteristics?

Answer: Transaction: It is a series of database operations and is the basic logical unit of database application.

Transaction characteristics:

(1) Atomicity: that is, indivisibility. Either all transactions are executed or none are executed.

(2) Consistency or stringability. The execution of a transaction converts the database from one correct state to another correct state

(3) Isolation. Before the transaction is correctly committed, any changes to the data by the transaction are not allowed to be provided to any other transaction,

(4) Persistence. After a transaction is submitted correctly, its results will be permanently saved in the database. Even if there are other failures after the transaction is submitted, the processing results of the transaction will be saved.

Or understand it this way:

A transaction is a group of SQL statements that are bound together as a logical unit of work. If any statement operation fails, the entire operation will fail, and subsequent operations will Roll back to the state before the operation, or there is a node on it. To ensure that something is either executed or not executed, transactions can be used. To consider a grouped statement as a transaction, it needs to pass ACID tests, namely atomicity, consistency, isolation and durability

3. What is the difference between char and varchar?

Answer: It is a fixed-length type, while varchar is a variable-length type. The difference between them is:

In a data column of type char(M), each value occupies M bytes. If a certain length is less than M, MySQL will pad it with space characters on the right. (Padding space characters will be removed during the search operation.) In a varchar(M) type data column, each value only takes up just enough bytes plus one byte to record its length ( That is, the total length is L+1 bytes).

4. Mysql storage engine, the difference between myisam and innodb.

Answer: Simple expression:

MyISAM is a non-transactional storage engine; suitable for frequent Query application; table lock, no deadlock; suitable for small data, small concurrency

innodb is a storage engine that supports transactions; suitable for applications with many insert and update operations; row lock if designed properly (The biggest difference lies in the lock level); suitable for big data and large concurrency.

5. What are the data table types?

## Answer: MyISAM, InnoDB, HEAP , BOB, ARCHIVE, CSV, etc.

MyISAM: Mature, stable, easy to manage, and fast to read. Some functions do not support (transactions, etc.), table-level locks.

InnoDB: supports transactions, foreign keys and other features, and data row locking. It takes up a lot of space and does not support full-text indexing, etc.

Part Three: PHP Interview Questions: Object-Oriented

1. What is object-oriented? (Answer with understanding)

## Answer: Object-oriented OO = Object-oriented analysis OOA + Object-oriented design OOD + Object-oriented programming OOP; The popular explanation is that "everything is an object", and all things are regarded as independent objects (units). They can complete their own functions by themselves, rather than being divided into functions like C.

The current pure OO languages ​​are mainly Java and C#. PHP and C++ also support OO. C is process-oriented. ​

#2. Briefly describe the access rights of private, protected, and public modifiers.

Answer: private: Private members can only be accessed inside the class.

protected: Protected members, accessible within the class and inherited classes.

public: Public members, completely public, no access restrictions.

3. What is the difference between heap and stack?

Answer: The stack is a memory space allocated during compilation, so the size of the stack must be clearly defined in your code;

The heap is where the program runs During the dynamically allocated memory space, you can determine the size of the heap memory to be allocated based on the running status of the program.

4. What are the characteristics of object-oriented?

Answer: Mainly include encapsulation, inheritance, and polymorphism. If it is 4 aspects, add: abstraction.

5. What is a constructor, what is a destructor, and what is its function?

Answer: The constructor (method) is the first method automatically called by the object after the object is created. It exists in every declared class and is a special

member method. Its function is to perform some initialization tasks. In Php, construct() is used to declare a constructor method, and only one can be declared.

The destructor (method) has the opposite effect to the constructor. It is the last method automatically called by the object before it is destroyed. It is a newly added content in PHP5 that is used to perform some specific operations before destroying an object, such as closing files and releasing memory.

Summary:

#php interview questions are different for each company, here we provide some We have summarized the more commonly encountered PHP interview questions, but you can also expand and extend yourself based on the PHP interview questions we summarized!

##Related recommendations:

1.

2017 Recruitment Season: Super Summary of PHP Interview Questions! 2.

11 Most Frequently Asked PHP Interview Questions

3.

Sharing PHP Interview Questions

The above is the detailed content of The most comprehensive summary of PHP interview questions and answers in 2017. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn