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

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

echo pow(2,3);
+4
source share
1 answer

In php 5.6 +

there is an example operator **.
$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)

**better than that pow(,).
When you try to write a mathematical algorithm. **- a powerful operator.
 there is no functional difference between him and the steppe.
power failure

+7
source

Source: https://habr.com/ru/post/1527125/


All Articles