Home >Backend Development >PHP Problem >How to find the power of a number in php

How to find the power of a number in php

青灯夜游
青灯夜游Original
2022-03-10 19:15:164284browse

How to find the power of a number: 1. Use the built-in function pow() to calculate the Nth power of a number. The syntax is "pow (value, power)"; 2. Use "**" Operator to calculate the Nth power of a number, the syntax is "numeric ** power".

How to find the power of a number in php

The operating environment of this tutorial: windows7 system, PHP7.2 version, DELL G3 computer

How to find a php Counting to several powers

For example:

How to find the power of a number in php

The following two methods are introduced:

1 , Use the built-in function pow() to calculate the Nth power of a number

<?php
$i=2;
$n=8;
echo pow($i,$n);
?>

How to find the power of a number in php

##2. Use the operator (**) Calculate the Nth power of a number

<?php
$i=2;
$n=8;
echo $i**$n;  //打印结果:256
?>

How to find the power of a number in php

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of How to find the power of a number in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn