Home> headlines> body text

2017 recruitment season: Super summary of PHP interview questions!

大家讲道理
Release: 2018-05-11 13:50:55
Original
21231 people have browsed it

The atmosphere is full of warmth. It’s the annual peak season for IT recruitment. As the saying goes, there are three golds and four silvers. Every company is recruiting hard, and everyone who is looking for a job or changing jobs is also looking for one. When entering a good company, your skills are the most important, but your application skills cannot be ignored. PHP Chinese website has summarized comprehensive PHP interview questions for your reference! (2017 Recruitment Season: How is the PHP salary and benefits?)

Basic PHP interview questions

1, double quotation marks and The difference between single quotes

  • Double quotes interpret variables, single quotes do not interpret variables

  • Insert single quotes inside double quotes, where if If there is a variable, the variable explanation

  • The double-quoted variable name must be followed by a special character other than a number, letter, or underscore, or the variable must be enclosed in {}, otherwise it will The part after the variable name is treated as a whole, causing a syntax error

  • Double quotes interpret escape characters, single quotes do not interpret escape characters, but interpret '\ and \\

  • can make single quote characters use single quotes as much as possible. Single quotes are more efficient than double quotes (because double quotes need to be traversed first to determine whether there are variables inside, and then operate, while single quotes No need to judge)

2. Commonly used super global variables (8)

  • $_GET ----->get Transmission method

  • $_POST ----->post transmission method

  • ##$_REQUEST ----->can be received Values in both get and post methods


  • $GLOBALS ----->All variables are placed inside

  • $_FILES ----->Upload files using

  • ##$_SERVER ----->System environment variables

    $_SESSION ----->Session control will use
  • $_COOKIE -----> ;Will be used during session control
  • 3. The difference between POST, GET, PUT, and DELETE methods in HTTP

HTTP defines how to interact with the server Different methods, the most basic ones are POST, GET, PUT, and DELETE. The full name of URL, which is indispensable, is resource descriptor. We can understand it like this: url describes a resource on the network, while post, get, put, and delegate It is to add, delete, modify and check this resource!

3.1 The difference between get and post submission methods in the form
    Get adds the parameter data queue to the URL pointed to by the action attribute of the submitted form. The value corresponds one-to-one with each field in the form, which can be seen from the URL; post uses the HTTPPOST mechanism to prevent each field in the form and its content from being transmitted together in the HTML head to the URL address pointed to by the action attribute. Users cannot see it. To this process
  • For the get method, the server uses Request.QueryString to obtain the value of the variable. For the post method, the server uses Request.Form to obtain the submitted data
  • The amount of data transmitted by get is small, and the amount of data transmitted by post is larger. It is generally unrestricted by default. However, in theory, the maximum amount is 80kb in IIS4 and 1000k in IIS5. Get is very secure. Low, post security is high
  • 3.2
    The GET request will send a request for data to the database to obtain information. This request Just like the select operation of the database, it is only used to query data. It will not modify or add data, and will not affect the content of the resource, that is, the request will not have side effects. No matter how many times you perform the operation, the result is the same.
  • Different from GET, the PUT request sends data to the server to change the information. This request is just like the update operation of the database, used to modify the content of the data, but The types of data will not be increased, which means that no matter how many PUT operations are performed, the results will not be different.
  • POST request is similar to PUT request, both send data to the server, but this request will change the type of data and other resources, just like the insert operation of the database, it will create new Content. Almost all current submission operations are requested using POST.
  • DELETE request, as the name suggests, is used to delete a certain resource. This request is like the delete operation of the database.
  • 4. Introduction to PHP

Hypertext Preprocessor----Hypertext Preprocessor

Personal Home Page Original Name

Target purpose:

Allows web developers to quickly write dynamically generated web pages. Compared with other pages, PHP embeds the program into the HTML document for execution, which is much more efficient than CGI that completely generates HTML editing

HTML:

Hypertext Markup Language

Founder:

Rasmus Lerdorf, born in 1968, University of Waterloo, Canada

Ledolf initially wrote the maintenance program in prel language in order to maintain his personal web page, and then rewritten it in c, which eventually led to php/fi

Timeline:

  • ##1995.06.08 PHP/FI will be released to the public

  • 1995 php2.0, adding support for MySQL

  • 1997 php3.0

  • 2000 php4.0

  • 2008 php5.0

  • Since php6.0 does not completely solve Unicode encoding, there are basically no applications on the production line. It is basically just a concept product. Many functions have been implemented on php5.3.3 and php5.3.4

Common IDE(Intergrated Development Environment):Integrated Development Environment

  • Coda (mac)

  • PHPStrom

  • Adobe Dreamweaver

  • NetBeans

Common text editors , with code highlighting:

  • NodePad++

  • ##SublimeText
  • PHP Advantage

PHP features:

    php uniquely mixes C, Java, Prel and PHP’s own syntax
  • Can execute dynamic web pages faster than CGI or Prel. Compared with other programming languages, PHP embeds programs into HTML documents for execution. The execution efficiency is much higher than CGI that completely generates HTML editing. All CGI can be realized
  • Supports almost all popular databases and operating systems
  • PHP can use C and C++ to extend the program
PHP Advantages:

    Open source
  • Free sex
  • Quickness
  • Strong cross-platform
  • ##High efficiency
  • Graphics processing
  • Object-oriented
  • Professional focus
  • PHP technology application :

Static page generation
  • Database caching
  • Process caching
  • p+css w3c standard
  • Big load
  • Distributed
  • flex
  • Support MVC
  • Smarty module engine
  • PHP certification level

Junior IFE: Index Front Engineer Front-end Engineer
  • Intermediate IPE: Index PHP Engineer PHP Engineer
  • Senior IAE: Index Architecture Engineer Architecture Engineer
  • 6. The difference between echo, print_r, print, var_dump
  • * echo、print是php语句,var_dump和print_r是函数 * echo 输出一个或多个字符串,中间以逗号隔开,没有返回值是语言结构而不是真正的函数,因此不能作为表达式的一部分使用 * print也是php的一个关键字,有返回值 只能打印出简单类型变量的值(如int,string),如果字符串显示成功则返回true,否则返回false* print_r 可以打印出复杂类型变量的值(如数组、对象)以列表的形式显示,并以array、object开头,但print_r输出布尔值和NULL的结果没有意义,因为都是打印"\n",因此var_dump()函数更适合调试 * var_dump() 判断一个变量的类型和长度,并输出变量的数值
    Copy after login
7. HTTP status code

2017 recruitment season: Super summary of PHP interview questions!

2017 recruitment season: Super summary of PHP interview questions!

2017 recruitment season: Super summary of PHP interview questions!

2017 recruitment season: Super summary of PHP interview questions!

2017 recruitment season: Super summary of PHP interview questions!

#Common HTTP status codes:2017 recruitment season: Super summary of PHP interview questions!

200 - Request successful

  • 301 - Resource ( Web page, etc.) is permanently escaped to a different URL

  • 404 - The requested resource (Web page, etc.) does not exist

  • 505 - Internal server error

  • HTTP status code classification:

1** - Information, request received by the server, requires the requester Continue the operation

  • 2** - Success, the operation was successfully received and processed

  • 3** - Redirect, further action required to complete the request

  • 4** - Client error, the request contained a syntax error or the request could not be completed

  • 5** Server error, the server An error occurred during the processing of the request


  • 8. What are magic quotes

  • Magic quotes are a symbol that will automatically convert the data entering the PHP script. In the process of definition, it is best not to escape when encoding but to escape as needed during runtime

9. How to obtain the client's IP (requires an int) and the code of the server's IP

Client:

$_SERVER["REMOTE_ADDR"]; or getenv('REMOTE_ADDR')

ip2long for conversionServer:
gethostbyname('www .baidu.com')
10. Which tools to use for version controlcvs, svn, vss, git

11. Methods to optimize the database

Select the most applicable field attributes, reduce the width of the defined fields as much as possible, and try to set the fields to NOTNULL. For example, 'province' and 'gender' are best suited to ENUM

  • Use joins (JOIN) instead of subqueries

  • Use unions (UNION) to replace manually created temporary tables

  • Transactions Processing

  • Lock table, optimize transaction processing

  • Apply foreign keys, optimize lock table

  • 建立索引

  • 优化查询语句

12、是否使用过模板引擎?使用的模板引擎的名字是?

Smarty:Smarty算是一种很老的PHP模板引擎了,它曾是我使用这门语言模板的最初选择。虽然它的更新已经不算频繁了,并且缺少新一代模板引擎所具有的部分特性,但是它仍然值得一看。

13、对于大流量网站,采用什么方法来解决访问量的问题

  • 确认服务器硬件是否能够支持当前的流量

  • 数据库读写分离,优化数据表

  • 程序功能规则,禁止外部的盗链

  • 控制大文件的下载

  • 使用不同主机分流主要流量

14、语句include和require的区别是什么?为避免多次包含同一文件,可以用(?)语句代替他们

  • require是无条件包含,也就是如果一个流程里加入require,无论条件成立与否都会先执行require,当文件不存在或者无法打开的时候,会提示错误,并且会终止程序执行

  • include有返回值,而require没有(可能因为如此require的速度比include快),如果被包含的文件不存在的化,那么会提示一个错误,但是程序会继续执行下去

注意:包含文件不存在或者语法错误的时候require是致命的,而include不是

  • require_once表示了只包含一次,避免了重复包含

15、谈谈mvc的认识

由模型、视图、控制器完成的应用程序,由模型发出要实现的功能到控制器,控制器接收组织功能传递给视图

16、 说明php中传值与传引用的区别,并说明传值什么时候传引用?

变量默认总是传值赋值,那也就是说,当将一个表达式的值赋予一个变量时,整个表达式的值被赋值到目标变量,这意味着:当一个变量的赋予另外一个变量时,改变其中一个变量的值,将不会影响到另外一个变量

php也提供了另外一种方式给变量赋值:引用赋值。这意味着新的变量简单的引用(换言之,成为了其别名或者指向)了原始变量。改动的新的变量将影响到原始变量,反之亦然。使用引用赋值,简单地将一个&符号加到将要赋值的变量前(源变量)

对象默认是传引用
对于较大是的数据,传引用比较好,这样可以节省内存的开销


17、isset、empty、is_null的区别

isset 判断变量是否定义或者是否为空

变量存在返回ture,否则返回false 变量定义不赋值返回false unset一个变量,返回false 变量赋值为null,返回false
Copy after login

empty:判断变量的值是否为空,能转换为false的都是空,为空返回true,反之返回false。

"",0,"0",NULL,FALSE都认为为空,返回true 没有任何属性的对象都认为是空
Copy after login

is_null:检测传入的值(值、变量、表达式)是否为null

定义了,但是赋值为Null 定义了,但是没有赋值 unset一个变量
Copy after login

18、前端调试的工具

  • Firefox的firebug

  • Chrome的开发工具

  • Emmet

  • JSON格式校验工具

19. 简单描述mysql中,索引,主键,唯一索引,联合索引的区别,对数据库的性能有什么影响(从读写两方面)(新浪网技术部)

索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的引用指针。
普通索引(由关键字KEY或INDEX定义的索引)的唯一任务是加快对数据的访问速度。
普通索引允许被索引的数据列包含重复的值。如果能确定某个数据列将只包含彼此各不相同的值,在为这个数据列创建索引的时候就应该用关键字UNIQUE把它定义为一个唯一索引。也就是说,唯一索引可以保证数据记录的唯一性。
主键,是一种特殊的唯一索引,在一张表中只能定义一个主键索引,主键用于唯一标识一条记录,使用关键字 PRIMARY KEY 来创建。
索引可以覆盖多个数据列,如像INDEX(columnA, columnB)索引,这就是联合索引。
索引可以极大的提高数据的查询速度,但是会降低插入、删除、更新表的速度,因为在执行这些写操作时,还要操作索引文件。

20.数据库中的事务是什么?

事务(transaction)是作为一个单元的一组有序的数据库操作。如果组中的所有操作都成功,则认为事务成功,即使只有一个操作失败,事务也不成功。如果所有操作完成,事务则提交,其修改将作用于所有其他数据库进程。如果一个操作失败,则事务将回滚,该事务所有操作的影响都将取消。ACID 四大特性,原子性、隔离性、一致性、持久性。

21. Do you understand XSS attacks? How to prevent it?

XSS is a cross-site scripting attack. First, the cross-site scripting vulnerability is used to execute a script constructed by the attacker in a privileged mode, and then the unsafe Activex control is used to perform malicious behaviors.
Use the htmlspecialchars() function to filter the submitted content to materialize the special symbols in the string.

22.What causes SQL injection vulnerability? How to prevent it?

Cause of SQL injection: During the program development process, you did not pay attention to standard writing of SQL statements and filtering of special characters, resulting in the client being able to submit some SQL statements through global variables POST and GET for normal execution.

Ways to prevent SQL injection:
  1. Turn on magic_quotes_gpc and magic_quotes_runtime settings in the configuration file

  2. Used when executing sql statements addslashes converts sql statements

  3. Try not to omit double quotes and single quotes when writing Sql statements.

  4. Filter out some keywords in the sql statement: update, insert, delete, select, *.

  5. Improve your naming skills of database tables and fields, name some important fields according to the characteristics of the program, and choose names that are difficult to guess.

  6. Set register_globals to off in the Php configuration file and turn off global variable registration

  7. Control error messages and do not output error messages on the browser. Write error information to the log file.

23.What are the main attack methods on PHP websites?

  1. Command Injection

  2. eval Injection

  3. Client Script Insertion

  4. Cross Site Scripting (XSS)

  5. SQL injection attack(SQL injection)

  6. Cross Site Request Forgery Attack
    Forgeries, CSRF

  7. Session Hijacking

  8. Session Fixation

  9. HTTP Response Splitting

  10. File upload Vulnerability (File Upload Attack)

  11. Directory Traversal(Directory Traversal)

  12. Remote File Inclusion Attack(Remote Inclusion)

  13. Dynamic Function Injection Attack (Dynamic Variable
    Evaluation)

  14. URL attack(URL attack)

  15. Form Submission spoofed attack (Spoofed Form
    Submissions)

  16. HTTP request spoofed attack (Spoofed HTTP Requests)

24. What is in the framework Single entrance and multiple entrances, what are the advantages and disadvantages of single entrance?

  1. Multiple mouths complete user requests by accessing different files. A single entry only web program directs all requests to a script file.

  2. A single entrance makes it easier to control permissions and facilitate security checks on http requests.
    Disadvantages: The URL does not look so beautiful, especially not friendly to search engines.

25. For relational databases, indexing is a very important concept. Please answer a few questions about indexing:

a). The purpose of indexing is What?
  1. Quickly access specific information in the data table and improve retrieval speed

  2. Create a unique index to ensure the uniqueness of each row of data in the database table sex.

  3. Accelerate the join between tables

  4. When using grouping and sorting clauses for data retrieval, you can significantly reduce grouping and Sorting time

b) What is the negative impact of indexing on the database system?

Negative impact:
Creating and maintaining indexes takes time, and this time increases as the amount of data increases; indexes need to occupy physical space, not only tables need to occupy data Space, each index also needs to occupy physical space; when the table is added, deleted, modified, the index must be dynamically maintained, which reduces the data maintenance speed.

c) What are the principles for creating indexes for data tables?
  1. Create indexes on the most frequently used fields to narrow the scope of the query.

  2. Create indexes on frequently used fields that need to be sorted

d). Under what circumstances is it inappropriate to create an index?
  1. It is not appropriate to create indexes for columns that are rarely involved in queries or columns with many duplicate values.

  2. For some special data types, it is not appropriate to create indexes, such as text fields (text), etc.

26. Briefly describe the difference between MyISAM and InnoDB in MySQL database

The most important feature that distinguishes it from other databases is its plug-in table storage engine. Remember: the storage engine is based on tables, not databases.

The difference between InnoDB and MyISAM:

InnoDB storage engine:Mainly for OLTP (Online Transaction Processing, online transaction processing) applications, it is the first complete support ACID transaction storage engine (BDB's first storage engine to support transactions, has stopped development).

Features:

  • Row lock design, support foreign keys;

  • Supports consistent non-locking reads similar to Oracle style (ie: read operations will not generate locks by default);

  • InnoDB stores data Put it in a logical table space and managed by InnoDB itself. Starting from the MySQL 4.1 version, each InnoDB storage engine table can be stored in an independent ibd file;

  • InnoDB uses MVCC (Multi-version Concurrency Control: read cannot will block writing, and writing will not block reading) to obtain high concurrency, and implements the 4 isolation levels of the SQL standard (the default is REPEATABLE level);

  • InnoDB also provides High-performance and high-availability functions such as insert buffer, double write, adaptive hash index, and read ahead;

  • InnoDB uses a clustered method to store data in the table. Each object is stored in the order of the primary key (if the primary key is not explicitly specified when creating the table, InnoDB will generate a 6 for each row. byte ROWID, and use this as the primary key);

  • The InnoDB table will have three hidden fields: In addition to the 6-byte DB_ROW_ID mentioned above, there is also a 6-byte DB_TX_ID (Transaction ID) and 7-byte DB_ROLL_PTR (pointing to the address of the corresponding rollback segment). This can be seen through innodb monitor;

##MyISAM storage engine:is the storage engine officially provided by MySQL, mainly for OLAP (Online Analytical Processing, online analysis and processing) applications.Features:

  • does not support transactions, but supports table locations and full-text indexes. The operation speed is fast;

  • MyISAM storage engine table consists of MYD and MYI, MYD is used to store data files, and MYI is used to store index files. The MySQL database only caches its index files, and the caching of data files is left to the operating system itself;

    Starting from MySQL 5.0 version, MyISAM supports 256T of single table data by default;

27. Explain the difference between MySQL outer joins, inner joins and self-joins

First of all, what is a cross-join:Cross-join is also called Cartesian product. It means that it directly does not use any conditions. Match all records in one table to all records in another table.

Inner joinis a cross-connection with only conditions. Records that meet the conditions are filtered out according to a certain condition. Records that do not meet the conditions will not appear in the result set, that is, inner joins only connect Matching lines.Outer joinThe result set not only contains rows that meet the join conditions, but also includes all data rows in the left table, right table, orin both tables. These three types The situations are called left outer join, right outer join, and full outer join in turn.

Left outer join, also called left join, the left table is the main table, all records in the left table will appear in the result set, for those records that do not match in the right table, they still need to be displayed, on the right The corresponding field values are filled with NULL. Right outer join, also called right join, the right table is the main table, and all records in the right table will appear in the result set. Left joins and right joins are interchangeable, and MySQL currently does not support full outer joins.

28. Write the names of more than three MySQL database storage engines (tip: not case sensitive)

MyISAM, InnoDB, BDB (BerkeleyDB), Merge, Memory (Heap), Example , Federated,

Archive, CSV, Blackhole, MaxDB and more than a dozen engines

29. What is object-oriented? What are the main features? What are the major principles?

Object-oriented is a design pattern for programs, which helps improve the reusability of programs and makes the program structure clearer. The main features are: encapsulation, inheritance, and polymorphism.

Five basic principles: Single responsibility principle; Open and closed principle; Replacement principle; Dependency principle; Interface separation principle.

30. What is static routing and what are its characteristics? What is dynamic routing and what are its characteristics?

Reference answer:

Static routing is designed and constructed by system administrators The route specified in the routing table. It is suitable for situations where the number of gateways is limited and the network topology does not change frequently. Its disadvantage is that it cannot dynamically adapt to changes in network conditions. When the network conditions change, the routing table must be modified by the network administrator.
Dynamic routing is dynamically constructed by routing protocols. Routing protocols update the contents of routing tables in real time by exchanging routing information they possess. Dynamic routing can automatically learn the topology of the network and update the routing table. The disadvantage is that routing broadcast update information will occupy a large amount of network bandwidth.

31. Have you ever used Memcache cache? If so, can you briefly describe its working principle?

Memcahce stores all data in memory using a hash table. Each piece of data is composed of key and value. Each key is unique. When you want to access a certain value, first find it value and return the result.

Memcahce uses the LRU algorithm to gradually clear out expired data.

32. List the popular Ajax frameworks? Explain what is the implementation principle of Ajax and what role does json play in Ajax?

Popular Ajax frameworks include jQuery, Prototype, Dojo, and MooTools.

The working principle of Ajax is that the specified location of one page can load all the output content of another page. In this way, a static page can also obtain the returned data information from the database. Therefore, Ajax technology enables a static web page to communicate with the server without refreshing the entire page, reducing user waiting time, thereby reducing network traffic and enhancing the friendliness of the customer experience.
When using Ajax, it involves data transmission, that is, returning data from the server to the client. The server and client use different script languages to process data, which requires a common data format, XML and json. These are the two most commonly used ones, and json is simpler than XML.

33. Overview of the transaction rollback mechanism in Myql

A transaction is a sequence of database operations defined by the user. These operations are either done or not done at all. It is an indivisible unit of work. Transaction rollback refers to undoing the update operations to the database that have been completed by the transaction.

When you want to modify two different tables in the database at the same time, if they are not a transaction, when the first table is modified, an exception may occur during the modification process of the second table and it cannot be modified. At this time Only the second table is still in its unmodified state, while the first table has been modified. And when you set them as a transaction, when the first table is modified and the second table is modified abnormally and cannot be modified, the first table and the second table will return to the unmodified state. This is called transaction rollback.


The above 33 questions list some of the questions in the interview from easy to difficult. For students who want to change jobs, going through these questions can improve their performance in the interview. There is a lot of success rate, so here I wish everyone who is looking for a job can find a job that you are satisfied with!

Related labels:
source:php.cn
Statement of this Website
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
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!