...

View Full Version : Squaring with PHP



SDP2006
12-10-2003, 09:55 PM
How can I square using PHP? i.e. 2^2 = 4 and 4^2 = 16.

I've looked but can't find it in the manual anywhere.

Thanks......

Nightfire
12-10-2003, 10:09 PM
http://uk2.php.net/sqrt

SDP2006
12-10-2003, 10:37 PM
I don't want the square root. I want to square the number.

Dylan Leblanc
12-10-2003, 11:33 PM
Exponentiation doesn't use ^ or ** as you might be used to with other languages. To calculate "z equals y to the x" use:

$z = pow(y,x)

http://ca.php.net/manual/en/function.pow.php

SDP2006
12-11-2003, 02:17 AM
Thanks, Dylan.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum