Home  >  Article  >  PHP Framework  >  How to sum in thinkphp template

How to sum in thinkphp template

藏色散人
藏色散人Original
2022-12-06 10:32:071496browse

How to implement sum in thinkphp template: 1. Create a Show controller; 2. In the Show controller, create an index method to pass data to the template; 3. Create a digital array, Use assign to pass the array to the index.html page; 4. Render the page output results through the display method; 5. Use the array_sum function to calculate the sum of the array values ​​and output it on the page.

How to sum in thinkphp template

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How to find sum in thinkphp template?

Calculate the sum of array values ​​in Thinkphp template

Create a Show controller to explain how to calculate the sum of array values ​​in Thinkphp template.

How to sum in thinkphp template

In the Show controller, create an index method to pass data to the template.

How to sum in thinkphp template

In the index method, create an array of numbers and use assign to pass the array to the index.html page.

How to sum in thinkphp template

In the index method, the page is rendered and outputted through the display method.

How to sum in thinkphp template

In the index.html page, use the array_sum function to calculate the sum of the array values ​​and output it on the page.

How to sum in thinkphp template

Execute the index method of the Show controller in the browser and view the results.

How to sum in thinkphp template

Recommended study: "thinkPHP Video Tutorial"

The above is the detailed content of How to sum in thinkphp template. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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