** is new power operator instead of power() in php

前提是你 提交于 2019-12-01 14:54:13

问题


How to use new version of Power operator instead of pow() in new version of php (5.6)? Like:

echo pow(2,3);

回答1:


There is a sample ** operator in php 5.6 +

$i = 6;

$i **=2; //output 36

$out = $i ** 3 //output 216

echo 2 ** 3 ** 2; // 512 (not 64)
echo -3 ** 2; // -9 (not 9)
echo 1 - 3 ** 2; // -8
echo ~3 ** 2; // -10 (not 16)

** is better than pow(,) .
When you try to write a math algorithm. ** is a Powerful Operator.
there's no functional difference between it and pow.
power operator refrence



来源:https://stackoverflow.com/questions/21803213/is-new-power-operator-instead-of-power-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!