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.
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.
In the Show controller, create an index method to pass data to the template.
In the index method, create an array of numbers and use assign to pass the array to the index.html page.
In the index method, the page is rendered and outputted through the display method.
In the index.html page, use the array_sum function to calculate the sum of the array values and output it on the page.
Execute the index method of the Show controller in the browser and view the results.
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!