Home > Article > Backend Development > Summary of the latest classic PHP interview questions (Part 2)
Summary of PHP junior classic interview questions (Part 1)
isset determines whether the variable is defined or empty
变量存在返回ture,否则返回false 变量定义不赋值返回false unset一个变量,返回false 变量赋值为null,返回false
Empty: Determine whether the value of the variable is empty. Anything that can be converted to false is empty. If it is empty, it returns true, otherwise it returns false.
"",0,"0",NULL,FALSE都认为为空,返回true 没有任何属性的对象都认为是空
is_null: Check whether the incoming value (value, variable, expression) is null
定义了,但是赋值为Null 定义了,但是没有赋值 unset一个变量
Firefox firebug
Chrome development tools
Emmet
JSON format verification tool
Indexes are a special file (the indexes on the InnoDB data table are an integral part of the table space). They contain all records in the data table. reference pointer.
The only task of a normal index (an index defined by the keyword KEY or INDEX) is to speed up access to data.
Normal indexes allow indexed data columns to contain duplicate values. If you can determine that a certain data column will only contain values that are different from each other, you should use the keyword UNIQUE to define it as a unique index when creating an index for this data column. In other words, a unique index can ensure the uniqueness of data records.
The primary key is a special unique index. Only one primary key index can be defined in a table. The primary key is used to uniquely identify a record and is created using the keyword PRIMARY KEY.
The index can cover multiple data columns, such as the INDEX (columnA, columnB) index, which is a joint index.
Indexes can greatly improve the speed of data query, but will reduce the speed of inserting, deleting, and updating tables, because when performing these write operations, the index file must be operated.
A transaction is an ordered set of database operations as a unit. A transaction is considered successful if all operations in the group succeed, even if only one operation fails, the transaction is not successful. If all operations are completed, the transaction is committed and its modifications are applied to all other database processes. If an operation fails, the transaction is rolled back and the effects of all operations in the transaction are canceled. The four major characteristics of ACID are atomicity, isolation, consistency, and durability.
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.
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, which resulted in the client being able to submit some sql statements normally through global variables POST and GET. implement.
Turn on magic_quotes_gpc and magic_quotes_runtime settings in the configuration file
Used when executing sql statements addslashes Convert 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, turn off global variable registration
ControlError message, do not browse Output error information on the server and write the 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
Forgeries, CSRF
Session Hijacking
Session Fixation
HTTP Response Splitting
File upload Vulnerability(File Upload Attack)
Directory Traversal(Directory Traversal)
Remote File Inclusion Attack(Remote Inclusion)
Dynamic Variable
Evaluation
URL attack
Form Submit spoofed attack (Spoofed Form
Submissions)
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.
Disadvantages: The URL does not look so beautiful, especially not friendly to search engines.
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 joins between tables
When using grouping and sorting clauses for data retrieval, you can significantly reduce grouping in queries and sorting time
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.
Create an index on the most frequently used fields to narrow the query range.
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 suitable to create indexes, such as text fields (text), etc.
The most important feature that distinguishes it from other databases is its plug-in type 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;
Support similar to Oracle Style consistent non-locking read (ie: read operations will not generate locks by default);
InnoDB places the data in a logical table space and is performed by InnoDB itself manage. 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 cross join: Cross join Also called Cartesian product, it refers to directly matching all records in one table with all records in another table without using any conditions.
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 two tables. These three situations are called They are left outer join, right outer join, and full outer join.
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.
MyISAM, InnoDB, BDB (BerkeleyDB), Merge, Memory (Heap), Example , Federated,
Archive, CSV, Blackhole, MaxDB and more than a dozen engines
Object-oriented is a design pattern of a program, which helps improve the reusability of the program and makes the program structure clearer. The main features are: encapsulation, inheritance, and polymorphism.
FiveBasic principles: Single responsibility principle; Open and closed principle; Replacement principle; Dependency principle; Interface separation principle.
Reference answer:
Static routes are routes specified by routing tables designed and constructed by system administrators. It is suitable for networks 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 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 own. 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.
Memcahce stores all data in the 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 follow the steps to find it. value and return the result.
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.
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 are the two most commonly used, and json is simpler than XML.
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 can be modified. The two tables are still in their 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 is the detailed content of Summary of the latest classic PHP interview questions (Part 2). For more information, please follow other related articles on the PHP Chinese website!