What is the meaning of the multiplication operator’s declaration twice?

Asked

Viewed 88 times

3

How the multiplication operator works when declared twice, for example:

$valor = 10**5;

1 answer

2


Works as an operator Exponential

The exponential operator is used when we want to raise some value to power, this operator is represented in PHP by ( * * ) (Two Asterisk).

The Exponential Operator was introduced in PHP as of version 5.6.

<?php
  $num1 = 10;
  $num2 = 2;
  
  // 10*10
  $potencia = $num1 ** $num2;
  
  echo $potencia;
  
  /* O resultado exibido é => 100 */

For your example, 10 to 5 10**5 would be:

10*10*10*10*10 = ‭100.000‬

Browser other questions tagged

You are not signed in. Login or sign up in order to post.