Summary of Thinkphp questions in PHP interview questions
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)DefinitionDebug 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 MVCModel (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 numericaldata type ; (Field type verification has been mandatory since version 3.1)
(4) Use automatic verification andautomatic 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('APP_DEBUG', true); //加载框架入口文件 require './ThinkPHP/ThinkPHP.php';
configuration file , and then load the project's debugging configuration file. The advantages of debugging mode are:
Turn on logging, anyError 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题目!
相关推荐:
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.
