Summary of thinkphp Topics in PHP interview questions

Source: Internet
Author: User
Tags constant definition php framework
In the last few years when we go to a company to apply for a job, the interviewer has given us a PHP interview questions about thinkphp, because THINKP in recent years has been a lot of companies and programmers of all ages, Then we PHP Chinese network today to summarize under the PHP interview problem often encountered in the thinkphp topic, hope to help you!

thinkphp topic:

1. Common PHP Framework

Answer: thinkphp

Yii

Zendframework

Cakephp

Sy

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

A: Thinkphp uses a single entry mode for project deployment and access, and no matter what functionality is completed, a project has a unified (but not necessarily unique) portal. It should be said that all projects are started from the entry file, and that the entry documents for all projects are similar, and the entry documents mainly include:

Define frame path, project path, and project name (optional)

Define relevant constants for debug mode and run mode (optional)

Load frame entry file (required)

3. What is the MVC hierarchy in thinkphp? Understand

A: MVC is a method of separating the logical and presentation layers of an application. Thinkphp is also based on the MVC design pattern. MVC is only an abstract concept, and there is no specific stipulation that the MVC hierarchy in thinkphp is broadly reflected in:

Model (M): the definition of a model is done by the models class.

Controller (C): Application Controller (core Controller app Class) and action controller both assume the role of the Controller, the action controller completes the business Process control, and the application controller is responsible for scheduling control.

View (V): Composed of the view class and template files, 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 that no model or view can work as well. It doesn't even depend on C, because Thinkphp has a master controller on the action, the app Controller, which is responsible for the overall scheduling of the application. In the absence of C, there must be a view V, otherwise it is no longer a complete application.

All in all, thinkphp's MVC model only provides a means of agile development, rather than sticking to MVC itself.

4.ThinkPHP How do I prevent SQL injection? Understand

A: (1) query conditions as far as possible using array mode, this is a more secure way;

(2) If forced to use string query conditions, the use of preprocessing mechanisms;

(3) Turn on data field type validation, you can cast the numeric data type, (3.1 version has been forced to verify the field type)

(4) using automatic verification and auto-completion mechanism for the application of custom filtering;

(5) Avoid the input of malicious data by using field type checking, automatic validation, and auto-completion mechanism.

5. How do I turn on debug mode? What are the benefits of debug mode?

A: Turning on debug mode is simple, just add a line of constant definition code to the portal file:

<? PHP,BV    //Open Debug mode    define (' App_debug ', true);    Load frame entry file    require './thinkphp/thinkphp.php ';

After the development phase is deployed to the production environment, you only need to remove the debug mode definition code to switch to the deployment mode. When debug mode is turned on, the system will load the default debug profile and then load the project's debug profile, with the advantage of the debug mode:

Turn on logging, any error messages and debugging information will be recorded in detail, easy to debug;

Close the template cache, template modification can be effective immediately;

Log SQL logs for easy analysis of SQL;

Close the field cache, and the data table fields are not affected by the cache;

Strictly check file capitalization (even on Windows platforms) to help you discover Linux deployment issues ahead of time;

Can be easily used at different stages of the development process, including development, testing, and presentation, and can be configured with separate project profiles for different application patterns.


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

A: thinkphp supports four URL patterns, which can be defined by setting the Url_model parameter, including normal mode, PATHINFO, rewrite, and compatibility mode.

The default mode is: PathInfo mode, set Url_model to 1

7. What are the system variables in TP? How do I get system variables?

Answer: How to get System variables:

You only need to call the following method in the action:

$this, Method name ("Variable name", ["Filter Method"],["Default value"])

8. What is the difference between the D function and the M function in the thinkphp framework?

A: The M method instantiation model does not require the user to define a model class for each data table, the D method automatically detects the model class, and if there is a custom model class, instantiates the custom model class and, if it does not exist, automatically invokes the M method to instantiate the model base class. Also, for a model that has been instantiated, it is not repeated to instantiate (singleton mode).

Summarize:

In the PHP interview problem also has a lot of thinkphp topic, here we do not list out, this to everyone is in the interview is more often asked thinkphp topic!

Related recommendations:

    1. 2017 Most complete PHP interview questions and answers summary

    2. 2017 recruitment season: PHP face test questions Super strong summary!

    3. 11 Most frequently asked PHP face questions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.