search
HomeBackend DevelopmentPHP TutorialSummary of Thinkphp questions in PHP interview questions
Summary of Thinkphp questions in PHP interview questionsNov 09, 2017 pm 01:33 PM
phpthinkphpSummary

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
thinkphp是不是国产框架thinkphp是不是国产框架Sep 26, 2022 pm 05:11 PM

thinkphp是国产框架。ThinkPHP是一个快速、兼容而且简单的轻量级国产PHP开发框架,是为了简化企业级应用开发和敏捷WEB应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。

一起聊聊thinkphp6使用think-queue实现普通队列和延迟队列一起聊聊thinkphp6使用think-queue实现普通队列和延迟队列Apr 20, 2022 pm 01:07 PM

本篇文章给大家带来了关于thinkphp的相关知识,其中主要介绍了关于使用think-queue来实现普通队列和延迟队列的相关内容,think-queue是thinkphp官方提供的一个消息队列服务,下面一起来看一下,希望对大家有帮助。

thinkphp的mvc分别指什么thinkphp的mvc分别指什么Jun 21, 2022 am 11:11 AM

thinkphp基于的mvc分别是指:1、m是model的缩写,表示模型,用于数据处理;2、v是view的缩写,表示视图,由View类和模板文件组成;3、c是controller的缩写,表示控制器,用于逻辑处理。mvc设计模式是一种编程思想,是一种将应用程序的逻辑层和表现层进行分离的方法。

实例详解thinkphp6使用jwt认证实例详解thinkphp6使用jwt认证Jun 24, 2022 pm 12:57 PM

本篇文章给大家带来了关于thinkphp的相关知识,其中主要介绍了使用jwt认证的问题,下面一起来看一下,希望对大家有帮助。

thinkphp 怎么查询库是否存在thinkphp 怎么查询库是否存在Dec 05, 2022 am 09:40 AM

thinkphp查询库是否存在的方法:1、打开相应的tp文件;2、通过“ $isTable=db()->query('SHOW TABLES LIKE '."'".$data['table_name']."'");if($isTable){...}else{...}”方式验证表是否存在即可。

thinkphp扩展插件有哪些thinkphp扩展插件有哪些Jun 13, 2022 pm 05:45 PM

thinkphp扩展有:1、think-migration,是一种数据库迁移工具;2、think-orm,是一种ORM类库扩展;3、think-oracle,是一种Oracle驱动扩展;4、think-mongo,一种MongoDb扩展;5、think-soar,一种SQL语句优化扩展;6、porter,一种数据库管理工具;7、tp-jwt-auth,一个jwt身份验证扩展包。

一文教你ThinkPHP使用think-queue实现redis消息队列一文教你ThinkPHP使用think-queue实现redis消息队列Jun 28, 2022 pm 03:33 PM

本篇文章给大家带来了关于ThinkPHP的相关知识,其中主要整理了使用think-queue实现redis消息队列的相关问题,下面一起来看一下,希望对大家有帮助。

thinkphp3.2怎么关闭调试模式thinkphp3.2怎么关闭调试模式Apr 25, 2022 am 10:13 AM

在thinkphp3.2中,可以利用define关闭调试模式,该标签用于变量和常量的定义,将入口文件中定义调试模式设为FALSE即可,语法为“define('APP_DEBUG', false);”;开启调试模式将参数值设置为true即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.