Home >PHP Framework >ThinkPHP >Common ThinkPHP framework interview written test questions and answers

Common ThinkPHP framework interview written test questions and answers

coldplay.xixi
coldplay.xixiforward
2020-08-10 17:09:335342browse

Common ThinkPHP framework interview written test questions and answers

#1. How to understand the single entry file in ThinkPHP?

ThinkPHP uses a single entry mode for project deployment and access. Using the ThinkPHP framework, no matter what project you do, there will be a unique entry file. This file is the starting point of the project. After entering the project, then Perform other operations.

Generally, the entry file will contain three parts:

Required:

1. Load the framework entry file

Optional:

2. Define the framework path, project path and project name

3. Define the related constants of debugging mode and running mode

Related topic recommendations: 2020 Thinkphp interview questions and answers (complete collection)

2. What is the MVC layering in ThinkPHP

MVC design idea is an abstraction The core of the concept is to separate the logic layer and view layer of the application.

The MVC used in ThinkPHP is roughly reflected in:

Model (M): Model data processing class;

Controller (C): Application controller (core Controller App class) and Action controller both assume the role of controller. Action controller completes business control, and application controller completes scheduling control.

View (V): consists of View class and view template file.

In ThinkPHP, it does not depend on M or V, which means it can work without a model or view. It doesn’t even rely on C. This is because ThinkPHP also has a master controller on top of Action, the App controller, which is responsible for the overall scheduling of the application. In the absence of C, view V must exist, otherwise it is no longer a complete application.

3. How to understand ThinkPHP architecture (Core Behavior Driven (CBD))

Core: ThinkPHP’s core code, MVC architecture, etc.;

Behavior: Some methods that come with the ThinkPHP framework, some reserved expansion locations, etc.;

Driver: ThinkPHP has built database driver, cache driver, tag library driver, template engine driver, etc., as well as some external Setup expansion; during the development process, you can directly use these drivers, which is simple and efficient.

4. How ThinkPHP prevents SQL injection

When ThinkPHP architecture was designed, some operations were carried out to prevent SQL injection.

The main things to pay attention to are:

If you can use Array for sql operation, use Array

When you must use Sql statements to operate, predict the content input by the user. ;For example, numerical type coercion, SQL keyword checking, regular expression matching, etc.

5. How to enable debugging mode? What are the benefits of debug mode?

To enable debugging mode, you only need to add a line of constant definition statement in the entry file before loading the framework entry file statement;

define("APP_DEBUG",true);

After turning on the debugging mode, the system will automatically open the following:

Operation logs, SQL logs and other logs, any errors will be recorded in detail to facilitate debugging;

Close the template file Caching, template modifications take effect immediately;

Turn off field caching, database field modifications are not affected by caching;

Strictly check file case, etc.

Debug mode is a Before the project goes online, it is a convenient tool for development, debugging, demonstration, etc.

6. What configuration modes are supported in ThinkPHP? What are the priorities?

ThinkPHP has created its own hierarchical configuration mode in terms of project configuration. The order of priority from right to left is:

Conventional configuration->Project configuration-> Debug configuration->Group configuration->Extended configuration->Dynamic configuration

7. What URL patterns does ThinkPHP support?

ThinkPHP supports 4 URL modes, which can be modified through the URL_MODEL parameter. The default is PATHINFO mode. The configuration values ​​0, 1, 2, and 3 are: normal mode, PATHINFO mode, REWRITE mode and compatible. Mode

8. What are the system variables in ThinkPHP? How to get system variables?

Commonly used system variables in ThinkPHP include: server, session, cookie, get, post, request

The output of system variables must use $Think. as a prefix, such as:

$Think.server.php_self = $_SESSION['php_self']

9. The difference between M method and D method in ThinkPHP (high frequency problem)

ThinkPHP uses two methods, M and D, to instantiate data model classes. The difference is that the M method directly instantiates the data model base class. The D method will check whether there is an inherited model class. If not, the function will be the same as M. The method is the same, if an inherited class exists, instantiate the inherited class.

Related learning recommendations:thinkphp

The above is the detailed content of Common ThinkPHP framework interview written test questions and answers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:chinacion. If there is any infringement, please contact admin@php.cn delete