Home > Backend Development > PHP Tutorial > Usage of functions related to thinkPHP template arithmetic operations

Usage of functions related to thinkPHP template arithmetic operations

不言
Release: 2023-03-31 09:44:01
Original
1508 people have browsed it

This article mainly introduces the usage of functions related to thinkPHP template arithmetic operations, and analyzes thinkPHP's related skills on arithmetic operations and parameter transfer in the form of simple examples. Friends in need can refer to the following

The examples in this article describe ThinkPHP template arithmetic operation related function usage. Share it with everyone for your reference, the details are as follows:

The function is defined as follows:

function you($num1,num2){
  echo $num1*$num2/100;
}
Copy after login

<volist name="list" id="vo">
 <tr>
<td>{$vo.price|you=$vo.discount&#39;}</td>或者:{$vo.price*$vo.discount/100}
 </tr>
</volist>
Copy after login

The parameter received as written above is Array.discount. The required operation does not have the correct result.

Modified the code:

<td>{$vo.price|you=$vo[&#39;discount&#39;]}</td>
<td>{$vo[&#39;price&#39;]*$vo[&#39;discount&#39;]/100}</td>
Copy after login

##Both of the above methods are available. It can be seen from this that thinkphp Templates do not support arithmetic operations and parameter passing in object mode.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

thinkphp uses model general data editing to add and delete

Analysis of variable output of ThinkPHP template engine

The above is the detailed content of Usage of functions related to thinkPHP template arithmetic operations. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template