Home Backend Development PHP Tutorial Summary of Thinkphp questions in PHP interview questions

Summary of Thinkphp questions in PHP interview questions

Nov 09, 2017 pm 01:33 PM
php thinkphp Summary

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:

1

2

3

4

5

<?Php,bv

    //开启调试模式

    define(&#39;APP_DEBUG&#39;, true);

    //加载框架入口文件

    require &#39;./ThinkPHP/ThinkPHP.php&#39;;

Copy after login

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中调用下面方法:

1

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

Copy after login

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 of this Website
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

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

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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 PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

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.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

How to solve the problem of cURL error 77 when connecting to Elasticsearch 8 using ThinkPHP6 and elasticsearch-php clients? How to solve the problem of cURL error 77 when connecting to Elasticsearch 8 using ThinkPHP6 and elasticsearch-php clients? Mar 31, 2025 pm 11:36 PM

Using the ThinkPHP6 framework combined with elasticsearch-php client to operate Elasticsearch...

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

See all articles