PHP right-associative operator ** denoting exponentiation (two multiplications)

Lecture



A right-associative operator ** was added to denote exponentiation. The short syntax ** = is also available.

<? php
printf ("2 ** 3 ==% d \ n", 2 ** 3);
printf ("2 ** 3 ** 2 ==% d \ n", 2 ** 3 ** 2);

$ a = 2;
$ a ** = 3;
printf ("a ==% d \ n", $ a);
?>

The result of this example:

 2 ** 3 == 8
 2 ** 3 ** 2 == 512
 a == 8 

Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Running server side scripts using PHP as an example (LAMP)

Terms: Running server side scripts using PHP as an example (LAMP)