Home  >  Article  >  Backend Development  >  Summary of Thinkphp questions in PHP interview questions

Summary of Thinkphp questions in PHP interview questions

黄舟
黄舟Original
2017-11-09 13:33:3019194browse

In the past few years, every time we went to a company to apply for a job, the interviewer gave us php interview questions, and there would be questions about thinkphp, because thinkp has been affected by many companies and programs in recent years. Therefore, our PHP Chinese website will give you a summary of thinkphp questions that are often encountered in PHP interview questions today. We hope it will be helpful to you!

Thinkphp topic:

1. Common PHP frameworks

Answer: thinkPHP

yii

ZendFramework

CakePhp

sy

##Related topic recommendations:

2020 thinkphp interview questions and answers (complete collection)

2. How to understand the single entry file in TP?

Answer: ThinkPHP uses a single entry mode for project deployment and access. No matter what function is completed, a project has a unified (but not necessarily the only) entry. It should be said that all projects start from the entry file, and the entry files of all projects are similar. The entry file mainly includes:

Define the framework path, project path and project name (optional)

Definition

Debug modeRelated constants for running mode (optional)

Load the framework entry file (required)

3. What is the MVC layering in ThinkPHP? (Understanding)

Answer: MVC is a method of separating the logical layer and presentation layer of an application. ThinkPHP is also based on the MVC

design pattern. MVC is just an abstract concept and has no particularly clear regulations. The MVC layering in ThinkPHP is roughly reflected in:

Model (M): The definition of the model is completed by the Model class.

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

View (V): It is composed of View class and template file. The template is 100% separated and can be previewed and produced independently.

But in fact, ThinkPHP does not rely 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.

In short, ThinkPHP's MVC model only provides a means of agile development, rather than sticking to MVC itself.

4. How does ThinkPHP prevent SQL injection? (Understanding)

Answer: (1) Try to use arrays for query conditions, which is a safer way;

(2) Strings must be used as a last resort Query conditions, use preprocessing mechanism;

(3) Turn on data field type verification, you can force conversion of numerical

data type ; (Field type verification has been mandatory since version 3.1)

(4) Use automatic verification and

automatic completion mechanism to customize application-specific filtering;

(5) Use field type checking, automatic verification and automatic completion mechanism etc. to avoid the input of malicious data.

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

Answer: Turning on the debugging mode is very simple. You only need to add a line of constant definition code to the entry file:

<?Php,bv
    //开启调试模式
    define(&#39;APP_DEBUG&#39;, true);
    //加载框架入口文件
    require &#39;./ThinkPHP/ThinkPHP.php&#39;;

After completing the development phase and deploying to the production environment, you only need to delete the debug mode definition code to switch to deployment mode. After turning on debugging mode, the system will first load the system's default debugging

configuration file , and then load the project's debugging configuration file. The advantages of debugging mode are:

Turn on logging, any

Error messages and debugging information will be recorded in detail to facilitate debugging;

Turn off the template cache, template modifications can take effect immediately;

Record SQL logs to facilitate SQL analysis;

Turn off field caching, data table field modifications are not affected by caching;

Strictly check file case (even on Windows platform) to help you detect Linux deployment problems in advance;

can be used conveniently Different application modes can configure independent project configuration files for different stages of the development process, including development, testing, demonstration, and any other required situations.


6.What are the URL patterns in TP? Which is the default?

答:ThinkPHP支持四种URL模式,可以通过设置URL_MODEL参数来定义,包括普通模式、PATHINFO、REWRITE和兼容模式。

默认模式为:PATHINFO模式,设置URL_MODEL 为1

7、TP中系统变量有哪些?如何获取系统变量?

答:获取系统变量的方法:

只需要在Action中调用下面方法:

$this->方法名("变量名",["过滤方法"],["默认值"])

8、ThinkPHP框架中D函数与M函数的区别是什么?

答:M方法实例化模型无需用户为每个数据表定义模型类,D方法可以自动检测模型类,如果存在自定义的模型类,则实例化自定义模型类,如果不存在,则会自动调用M方法去实例化Model基类。同时对于已实例化过的模型,不会重复去实例化(单例模式)。

总结:

在php面试题中还有关于很多的thinkphp的题目、在这里我们就不一一列举出来了,这给大家介绍的是在面试中比较常被问的thinkphp题目!

相关推荐:

  1. 2017最全的php面试题目及答案总结

  2. 2017招聘季:PHP面试题超强总结!

  3. 11个提问频率最高的php面试题

The above is the detailed content of Summary of Thinkphp questions in PHP interview questions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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