If you just need to check if N is a perfect power of Base, log() is SLOW compared to a WHILE construct that will be 2x faster!
Tested on range: 1 ... 20.000.000 => while() is 2.105 times faster
<?php
$number='fill in your number here'
$base='fill in requested base here';
//use when the power is needed
$pow=0;do { $number/=$base;$pow++; } while ($number>1);
if ($number==1) print $base.'^'.$pow;
else print 'False';
//use when just a check is needed
do $number/=$base; while ($number>1);
if ($number==1) print 'True';
else print 'False';
?>