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
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)
$_GET ----->get Transmission method
$_POST ----->post transmission method
3.1 The difference between get and post submission methods in the form
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: Common IDE(Intergrated Development Environment): Integrated Development Environment Common text editors , with code highlighting:
Static page generation #Common HTTP status codes: 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 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 Client: ip2long for conversion 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 建立索引 优化查询语句 Smarty:Smarty算是一种很老的PHP模板引擎了,它曾是我使用这门语言模板的最初选择。虽然它的更新已经不算频繁了,并且缺少新一代模板引擎所具有的部分特性,但是它仍然值得一看。 确认服务器硬件是否能够支持当前的流量 数据库读写分离,优化数据表 程序功能规则,禁止外部的盗链 控制大文件的下载 使用不同主机分流主要流量 require是无条件包含,也就是如果一个流程里加入require,无论条件成立与否都会先执行require,当文件不存在或者无法打开的时候,会提示错误,并且会终止程序执行 include有返回值,而require没有(可能因为如此require的速度比include快),如果被包含的文件不存在的化,那么会提示一个错误,但是程序会继续执行下去 注意:包含文件不存在或者语法错误的时候require是致命的,而include不是 require_once表示了只包含一次,避免了重复包含 由模型、视图、控制器完成的应用程序,由模型发出要实现的功能到控制器,控制器接收组织功能传递给视图 变量默认总是传值赋值,那也就是说,当将一个表达式的值赋予一个变量时,整个表达式的值被赋值到目标变量,这意味着:当一个变量的赋予另外一个变量时,改变其中一个变量的值,将不会影响到另外一个变量 php也提供了另外一种方式给变量赋值:引用赋值。这意味着新的变量简单的引用(换言之,成为了其别名或者指向)了原始变量。改动的新的变量将影响到原始变量,反之亦然。使用引用赋值,简单地将一个&符号加到将要赋值的变量前(源变量) 对象默认是传引用 isset 判断变量是否定义或者是否为空 empty:判断变量的值是否为空,能转换为false的都是空,为空返回true,反之返回false。 is_null:检测传入的值(值、变量、表达式)是否为null Firefox的firebug Chrome的开发工具 Emmet JSON格式校验工具 索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的引用指针。 事务(transaction)是作为一个单元的一组有序的数据库操作。如果组中的所有操作都成功,则认为事务成功,即使只有一个操作失败,事务也不成功。如果所有操作完成,事务则提交,其修改将作用于所有其他数据库进程。如果一个操作失败,则事务将回滚,该事务所有操作的影响都将取消。ACID 四大特性,原子性、隔离性、一致性、持久性。 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. 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. Turn on magic_quotes_gpc and magic_quotes_runtime settings in the configuration file Used when executing sql statements addslashes converts sql statements Try not to omit double quotes and single quotes when writing Sql statements. Filter out some keywords in the sql statement: update, insert, delete, select, *. 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. Set register_globals to off in the Php configuration file and turn off global variable registration Control error messages and do not output error messages on the browser. Write error information to the log file. Command Injection eval Injection Client Script Insertion Cross Site Scripting (XSS) SQL injection attack(SQL injection) Cross Site Request Forgery Attack Session Hijacking Session Fixation HTTP Response Splitting File upload Vulnerability (File Upload Attack) Directory Traversal(Directory Traversal) Remote File Inclusion Attack(Remote Inclusion) Dynamic Function Injection Attack (Dynamic Variable URL attack(URL attack) Form Submission spoofed attack (Spoofed Form HTTP request spoofed attack (Spoofed HTTP Requests) Multiple mouths complete user requests by accessing different files. A single entry only web program directs all requests to a script file. A single entrance makes it easier to control permissions and facilitate security checks on http requests. Quickly access specific information in the data table and improve retrieval speed Create a unique index to ensure the uniqueness of each row of data in the database table sex. Accelerate the join between tables When using grouping and sorting clauses for data retrieval, you can significantly reduce grouping and Sorting time Negative impact: Create indexes on the most frequently used fields to narrow the scope of the query. Create indexes on frequently used fields that need to be sorted It is not appropriate to create indexes for columns that are rarely involved in queries or columns with many duplicate values. For some special data types, it is not appropriate to create indexes, such as text fields (text), etc. 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: Starting from MySQL 5.0 version, MyISAM supports 256T of single table data by default; 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 join is 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 join The result set not only contains rows that meet the join conditions, but also includes all data rows in the left table, right table, or in both tables. These three types The situations are called left outer join, right outer join, and full outer join in turn. Archive, CSV, Blackhole, MaxDB and more than a dozen engines Five basic principles: Single responsibility principle; Open and closed principle; Replacement principle; Dependency principle; Interface separation principle. 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. Memcahce uses the LRU algorithm to gradually clear out expired data. 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. 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!
PHP features:php uniquely mixes C, Java, Prel and PHP’s own syntax
PHP Advantages:Open source
Junior IFE: Index Front Engineer Front-end Engineer
* 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() 判断一个变量的类型和长度,并输出变量的数值
7. HTTP status code
8. What are magic quotes9. How to obtain the client's IP (requires an int) and the code of the server's IP
Server:
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
12、是否使用过模板引擎?使用的模板引擎的名字是?
13、对于大流量网站,采用什么方法来解决访问量的问题
14、语句include和require的区别是什么?为避免多次包含同一文件,可以用(?)语句代替他们
15、谈谈mvc的认识
16、 说明php中传值与传引用的区别,并说明传值什么时候传引用?
对于较大是的数据,传引用比较好,这样可以节省内存的开销17、isset、empty、is_null的区别
变量存在返回ture,否则返回false
变量定义不赋值返回false unset一个变量,返回false
变量赋值为null,返回false
"",0,"0",NULL,FALSE都认为为空,返回true
没有任何属性的对象都认为是空
定义了,但是赋值为Null
定义了,但是没有赋值 unset一个变量
18、前端调试的工具
19. 简单描述mysql中,索引,主键,唯一索引,联合索引的区别,对数据库的性能有什么影响(从读写两方面)(新浪网技术部)
普通索引(由关键字KEY或INDEX定义的索引)的唯一任务是加快对数据的访问速度。
普通索引允许被索引的数据列包含重复的值。如果能确定某个数据列将只包含彼此各不相同的值,在为这个数据列创建索引的时候就应该用关键字UNIQUE把它定义为一个唯一索引。也就是说,唯一索引可以保证数据记录的唯一性。
主键,是一种特殊的唯一索引,在一张表中只能定义一个主键索引,主键用于唯一标识一条记录,使用关键字 PRIMARY KEY 来创建。
索引可以覆盖多个数据列,如像INDEX(columnA, columnB)索引,这就是联合索引。
索引可以极大的提高数据的查询速度,但是会降低插入、删除、更新表的速度,因为在执行这些写操作时,还要操作索引文件。20.数据库中的事务是什么?
21. Do you understand XSS attacks? How to prevent it?
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?
Ways to prevent SQL injection:
23.What are the main attack methods on PHP websites?
Forgeries, CSRF
Evaluation)
Submissions)24. What is in the framework Single entrance and multiple entrances, what are the advantages and disadvantages of single entrance?
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?
b) What is the negative impact of indexing on the database system?
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?
d). Under what circumstances is it inappropriate to create an index?
26. Briefly describe the difference between MyISAM and InnoDB in MySQL database
27. Explain the difference between MySQL outer joins, inner joins and self-joins
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. 32. List the popular Ajax frameworks? Explain what is the implementation principle of Ajax and what role does json play in Ajax?
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