current location:Home > Technical Articles > PHP Framework > ThinkPHP

  • How to get the requested URL in thinkphp5
    How to get the requested URL in thinkphp5
    The method for thinkphp5 to obtain the requested URL: 1. Use the "$request=Request::instance();" method of the "\think\Request" class to obtain the current URL information; 2. Use the built-in helper function "$request-> url()" to obtain the complete URL address including the domain name. THINKPHP5 obtains the URL information of the current page. If you want to obtain the URL information of the current page, you can use the request class that comes with thinkphp to obtain the current URL information. Use \think\Request class $request=Request::in
    ThinkPHP 2234 2023-06-03 14:33:33
  • How thinkphp outputs registration success information on the front end
    How thinkphp outputs registration success information on the front end
    Below we will take a simple registration page as an example to explain. First, we need to build a form in the register.html page. The code is as follows: User name, password, and email address are registered in the form. We should notice {:url('User/register')} in the action attribute, which tells the system where After the user clicks the "Register" button, the form data will be submitted to the background and processed using the register() method. Next, we need to perform registration logic in the User controller
    ThinkPHP 1288 2023-06-03 13:57:48
  • How to remove duplicate queries in thinkphp5
    How to remove duplicate queries in thinkphp5
    1. Use the SELECTDISTINCT keyword. In SQL statements, you can use the SELECTDISTINCT keyword to obtain unique data. In ThinkPHP5, when using the query() method of the \think\Db class to execute a SQL query statement, you can directly use the SELECTDISTINCT keyword in the query conditions, for example: use\think\Db;$data=Db::query('SELECTDISTINCT `brand`FROM`goods`WHERE`
    ThinkPHP 2293 2023-06-03 13:44:41
  • How to output pictures in thinkphp
    How to output pictures in thinkphp
    Fixed path output pictures Sometimes we need to output one or more pictures on the page. The paths of these pictures are fixed. You can use thinkphp's helper function to achieve output. The specific method is as follows: 1. First, store the image in the public directory in thinkphp, such as public/images/logo.png. 2. Use tags in HTML to call the image. The code is as follows: where /images/logo.png is the relative path of the image, and / represents the website root directory. 3. After completion, save and refresh the page, and you will be able to see the image on the page. Dynamic path output pictures sometimes we need to output in thinkphp
    ThinkPHP 1032 2023-06-03 12:31:27
  • How to use ThinkPHP to implement comment function
    How to use ThinkPHP to implement comment function
    What is ThinkPHP First, let us understand what ThinkPHP is. ThinkPHP is a free and open source PHP development framework. Its emergence greatly simplifies the development of WEB applications. The ThinkPHP framework has rich functional modules, easy expansion and excellent performance. Implementation of the comment function in the ThinkPHP framework In the ThinkPHP framework, implementing the comment function is generally divided into the following steps: Create a database table. First, we need to create a table in the database to store comment information. This table should at least include the following Several fields: comment ID, article ID, commenter name, comment content, comment time, etc. Create review model in T
    ThinkPHP 1625 2023-06-03 12:13:25
  • How to turn off info information output in thinkphp5
    How to turn off info information output in thinkphp5
    1. The function of info Before we start to close info, we need to understand its function. In the ThinkPHP5 framework, there are three main forms of info information output: displaying the currently accessed URL and request parameters; displaying debugging information such as the SQL statement execution and running time of the current page at the bottom of the page; outputting detailed error information when an execution error occurs, which is convenient Although debugging seems useful, most of the info information is not very helpful to real developers. Often, what we need is some more concise output so we can better focus on development. 2. Close info. Closing info is very simple. You only need to configure
    ThinkPHP 1410 2023-06-03 11:49:08
  • what is the meaning of thinkphp ds
    what is the meaning of thinkphp ds
    thinkphpds means slash/; under window, it means backslash\ or slash/, but for compatibility with writing, it is recommended to use slash/; the use of ds is equivalent to "$info=$file->move(ROOT_PATH. 'public/uploads');". Specific problem description: What is the DS of thinkphp5Move method? $info=$file->move(ROOT_PATH.'public'.DS.'uploads');DS
    ThinkPHP 857 2023-06-03 10:46:47
  • How to set up a single page in thinkphp
    How to set up a single page in thinkphp
    1. What is a single-page application? A single-page application, also known as Single-Page Application in English, or SPA for short, is a web application based on technologies such as Ajax and HTML5 that optimizes user experience by dynamically loading partial content of the page. Unlike traditional applications, single-page applications only contain one HTML page, and the page content is dynamically loaded through JavaScript to achieve content presentation and switching between pages. 2. Create a single-page application There are many ways to create a single-page application in ThinkPHP, and this article will introduce one of them. 1. Create a controller. In ThinkPHP, all business logic is implemented in the controller.
    ThinkPHP 1383 2023-06-03 10:46:38
  • How to use thinkphp fetch method
    How to use thinkphp fetch method
    First of all, the fetch method is a rendering method in the ThinkPHP framework. This method is mainly used to load the view page and render it. This method is defined in the View class of the ThinkPHP framework, therefore, we need to find the View class first. The path of the View class in the ThinkPHP framework is as follows: thinkphp/library/think/View.php. We can find the source code file where the View class is located through this path. Open the View.php source file, we can see that the fetch() method is defined in the View class, its code is as follows: /***Rendering template output*@acces
    ThinkPHP 956 2023-06-03 08:43:21
  • How to turn off undefined variable prompt in thinkphp
    How to turn off undefined variable prompt in thinkphp
    1. Why undefined variables appear? Undefined variables usually appear in the following situations: Variables are spelled incorrectly. The variable has not been declared or assigned a value. Variable scope is incorrect. 2. How to turn off undefined variable prompts. In order to turn off undefined variable prompts, we can modify the php.ini file or configure it in the application. Below are detailed instructions for both methods. Modify the php.ini file. Open the php.ini file and find the error_reporting configuration item in it. Change its value to the following code: error_reporting=E_ALL&~E_NOTICE&~E_STRICT This configuration will turn off undefined variables
    ThinkPHP 1130 2023-06-03 08:40:09
  • How thinkphp accesses different templates based on device
    How thinkphp accesses different templates based on device
    How thinkphp accesses different templates according to the device: 1. Place "functionisMobile(){...}" in the "app\common.php" public method; 2. Set the prefix operation in the public method under the index module; 3. If it is judged to be true, execute the "mobile/index" method, otherwise execute another PC-side controller operation. thinkphp5 determines mobile or PC access and calls different templates. Place the following code in the app\common.php public method. functionisMobile(){if(isset($_SERV
    ThinkPHP 1026 2023-06-03 08:15:27
  • How to use the query correlation function of ThinkPHP
    How to use the query correlation function of ThinkPHP
    1. Model association 1.1 One-to-one association One-to-one association means that there is only one record in each of the two data tables. In this case, the hasOne() and belongTo() functions are used for association. Suppose we have two tables, one is the user table and the other is the userinfo table. The structure of the two tables is as follows: user:idnameuserinfo:iduser_idage. The above two tables are related through the field user_id. We now want to find the user information in the user table and the age of the user. The specific operations are as follows: define a userinfo() method in the User model, with a random method name. //User model
    ThinkPHP 1749 2023-06-03 08:01:17
  • How to turn off trace debugging mode in thinkphp
    How to turn off trace debugging mode in thinkphp
    Why turn off trace mode? Trace mode is ThinkPHP's own debugging mode. You can easily view relevant information of the current request at the bottom of the page, such as request parameters, SQL statements, etc., which is very helpful for problem location. However, in a production environment, we do not want this sensitive information to be leaked, thus affecting the security of the system. In addition, debugging mode will also bring certain performance losses, so it is necessary for us to turn it off. How to turn off trace mode? ThinkPHP enables trace mode by default. We can turn off trace mode by setting the app_debug parameter. in config
    ThinkPHP 1795 2023-06-02 22:53:55
  • How to add database configuration and operate data in thinkphp3.2
    How to add database configuration and operate data in thinkphp3.2
    1. Database configuration Create a new database.php file in the config folder and add the following configuration: returnarray('DB_TYPE'=>'mysql',//Database type 'DB_HOST'=>'localhost',//Server address 'DB_NAME' =>'
    ThinkPHP 1683 2023-06-02 22:40:57
  • How to use ThinkPHP to implement user permissions
    How to use ThinkPHP to implement user permissions
    1. Introduction In Web application systems, user rights management is an important part of system design. System administrators can control the visibility and operability of pages and control user access rights through user rights management. User permissions are divided into the following aspects: Page access permissions Data access permissions Data operation permissions 2. The process of using ThinkPHP to implement user permissions The following is the process of using ThinkPHP to implement user permissions: Create a permission table First we need to create it in the database A permission table, which contains the following fields: idint(11) primary key, auto-increment namevarchar(255) permission name urivarchar(2)
    ThinkPHP 1098 2023-06-02 22:25:28

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28