I’m learning PHP and was experimenting with progressively harder code. (Obviously, I haven’t gotten very far.) I seem to be having trouble with functions, as the following code outputs ‘3’ instead of ‘81’ (the sought answer).
Could someone explain what I did incorrectly? The language I am most familiar with is Java.
Thanks!!
[php]
<?php function power($base, $power) { $result = 0; if($power = 0) { $result = 1; } else { $result = $base; for($i=0; $i<$power; $i++) { $result = $result * $base; } } return $result; } echo power(3,4); ?>[/php]