Usage analysis of functions related to thinkPHP template arithmetic operations

不言
Release: 2023-03-25 11:42:02
Original
1346 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. Friends in need can refer to the following

This article describes the use of thinkPHP template arithmetic operations with examples 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.

Related recommendations:

Detailed introduction to the method of distinguishing 0, null and false in the ThinkPHP template tag eq if


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

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!