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';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, 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!

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

Setting the httponly flag is crucial for session cookies because it can effectively prevent XSS attacks and protect user session information. Specifically, 1) the httponly flag prevents JavaScript from accessing cookies, 2) the flag can be set through setcookies and make_response in PHP and Flask, 3) Although it cannot be prevented from all attacks, it should be part of the overall security policy.

PHPsessionssolvetheproblemofmaintainingstateacrossmultipleHTTPrequestsbystoringdataontheserverandassociatingitwithauniquesessionID.1)Theystoredataserver-side,typicallyinfilesordatabases,anduseasessionIDstoredinacookietoretrievedata.2)Sessionsenhances

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.


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

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),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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