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 
created: 2017-07-03
updated: 2026-03-08
137



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


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

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

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