1. What is object oriented? What are the main features?

Object oriented is a design method of program, which is beneficial to improve the reuse of program and make the program structure more clear.

Main features: encapsulation, inheritance, polymorphism.

2. What is the difference between SESSION and COOKIE? Please explain the reasons and functions in terms of protocol?

HTTP is a stateless protocol, which cannot distinguish whether a user is from the same website or not. The same user requesting different pages cannot be regarded as the same user.

The SESSION is stored on the server and the COOKIE is stored on the client. Session is secure, cookie can be modified by some means, not secure. Sessions rely on cookies for delivery. After cookies are disabled, the session cannot be used normally. Disadvantages of the Session: The Session is saved on the server side, and each read is read from the server, which consumes resources on the server. Session is stored in a file or database on the server side. By default, it is stored in a file. The file path is specified in the PHP configuration file session.save_path. Session files are public.

3. What are the codes 302, 403, and 500 in HTTP status?

Principle 1, 2, 3, 4, 5: (i.e. 1: message series; Two: successful series; Three: redirection series; Four: request error series; Five: server side error series.

  • 302: Temporary transfer succeeded. The requested content has been moved to the new location
  • 403: Access is prohibited
  • 500: The server has an internal error
  • 401: Indicates unauthorized

Int char varchar datetime text int char varchar datetime text What is the difference between varchar and char?

  • Int integer
  • Char Specifies the fixed length character
  • Varchar Variable length character
  • Datetime Indicates the date or time type
  • The Text Text type

The difference between Varchar and char Char is a fixed-length character type that takes up as much space as it allocates. Varchar is a variable length character type, which takes up as much space as the content. It can effectively save space. Since the vARCHar type is mutable, the server performs additional operations when the data length changes, which is less efficient than the CHAR type.

5. The basic differences between MyISAM and InnoDB? How is the index structure implemented?

MyISAM type does not support transactions, table locking, easy to produce fragmentation, often optimized, fast read and write, suitable for frequent query applications;

InnoDB type supports transaction, row lock, crash recovery ability, read and write speed is slower than MyISAM, suitable for insert and update operation more applications, large space, does not support full text index, etc.

Create index: alert table tablename add index

6. Difference between isset() and empty()

Isset checks whether a variable exists. Multiple variables can be passed in. If one of them does not exist, false is returned. Empty determines whether a variable is empty or false. Only one variable can be passed. If it is empty or false, it returns true.

7. Explain the difference between passing values and passing references in PHP. When do you pass values and when do you pass references?

Value passing: Any change to a value within the scope of a function is ignored outside the function

Pass by reference pass: Any changes to values within the scope of a function are also reflected outside the function

Pros and cons: When passing values, PHP must copy values. Especially for large strings and objects, this can be an expensive operation. Passing by reference does not require copying values, which is great for performance.

What does error_reporting do in PHP?

Sets PHP’s error level and returns the current level.

9. What do you know about caching?

Caching technology is to cache dynamic content in a file and call the cache file directly when accessing the dynamic page within a certain period of time without having to revisit the database.

10. Now the MVC three-tier structure is often adopted in programming. Which three layers do MVC refer to and what are the advantages?

MVC three layers respectively refer to business model, view and controller. The controller layer calls the model to process data, and then maps the data to the view layer for display

The advantages are as follows: (1) It can realize code reuse and avoid code redundancy; ②M and V implementation code separation, so that the same program can use different forms of expression

11. What are the advantages of AJAX?

Ajax is an asynchronous transfer technology, which can be implemented through javascript or JQuery framework to achieve local refresh, reducing the pressure on the server and improving the user experience.

12, in the development of the program, how to improve the operation efficiency of the program?

Optimize SQL statements, try not to use SELECT * in query statements, which field to check which field; Use less subqueries instead of table joins; Use less fuzzy query;

Create index in data table;

Generate a cache for frequently used data in your program.

13, for large traffic sites, what kind of method do you use to solve the problem of traffic?

  • Use caching effectively to increase cache hit ratio
  • Using load Balancing
  • Static files are stored and accelerated using CDN
  • Try to reduce your database usage
  • Where is the bottleneck for viewing statistics
  • The reverse proxy

What is the difference between the statement include and require? To avoid including the same file more than once, what statements can replace them?

Difference: include generates a warning in case of failure, whereas require generates an error interrupt. Require loads include at run time instead of require_onceinclude_once

15. What’s the difference between foo() and @foo()?

@ indicates that all warning is ignored

16. Briefly describe PHP’s garbage collection mechanism.

Variables in PHP are stored in the variable container Zval, which stores the variable type and value as well as is_REF and refcount fields. Refcount indicates the number of elements pointing to a variable, and is_ref indicates whether the variable has an alias. If refCount is 0, the variable container is reclaimed. If a zval’s refcount decreases by 1 and is greater than 0, it goes into the garbage buffer. When the buffer reaches its maximum value, the collection algorithm loops through the zval to determine whether it is garbage and releases it.

17. How to maximize SECURITY in PHP?

How to avoid SQL injection vulnerability and XSS cross-site scripting vulnerability? A: Basic rules: Don’t show server or programming details to the outside world (block errors), don’t trust any user-submitted data (filter user-submitted data).

Echo, print_r, print, var_dump

  • Echo: statement structure;
  • Print: is a function that returns a value
  • Print_r: Can print arrays, objects
  • Var_dump: can print an array of objects with data types

Write down the features of the Smarty template

Fast, compiled, cache technology, plug-in mechanism, powerful presentation logic

20. If you want to output user input as is, which function should be used to process the data before it is stored?

The htmlspecialchars or htmlentities

Pay attention and don’t get lost

All right, everybody, that’s all for this article. All the people here are talented. As mentioned before, there are many technical points in PHP, because there are too many, it is really difficult to write, you will not read too much after writing, so I have compiled it into PDF and document, if you need to click hereShimo. Im/docs/Jky8td…>>> How to grow as an architect