<?php
$x = 3 ;
$y = 4 ;
$power = 1 ;
for ( $i = 1 ; $i <= $y ; $i ++ )
$power = $power * $x ;
echo $x . ' raised to the power ' . $y . ' = ' . $power ;
// improved by Tempérance K.
$Nx = 3 ;
$Ny = 4 ;
$Npower = 1 ;
echo "\n \n --------------------------------------\n \n " ;
// Boucle for qui calcule la valeur de Nx puissance i puis multiplie power par résultat de calcul précédent
for ( $i = 1 ; $i <= $Ny ; $i ++ ) {
$Nresult = pow ( $Nx , $i ) ; // Equivaut à faire "Nx * Nx * "...$i fois" $Npower *= $Nresult ;
echo "$Nx raised to the power of $Ny equals $Npower " ;
echo "\n " ;
}
PD9waHAKCgokeD0zOwokeT00OwokcG93ZXI9MTsKCmZvcigkaT0xOyRpPD0keTskaSsrKQogJHBvd2VyPSRwb3dlciokeDsKICBlY2hvICR4LicgcmFpc2VkIHRvIHRoZSBwb3dlciAnLiR5LicgPSAnLiRwb3dlcjsKIAovLyBpbXByb3ZlZCBieSBUZW1ww6lyYW5jZSBLLgokTnggPSAzOwokTnkgPSA0OwokTnBvd2VyID0gMTsKCgplY2hvICJcblxuLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cblxuIjsKCi8vIEJvdWNsZSBmb3IgcXVpIGNhbGN1bGUgbGEgdmFsZXVyIGRlIE54IHB1aXNzYW5jZSBpIHB1aXMgbXVsdGlwbGllIHBvd2VyIHBhciByw6lzdWx0YXQgZGUgY2FsY3VsIHByw6ljw6lkZW50CmZvciAoJGkgPSAxOyAkaSA8PSAkTnk7ICRpKyspIHsKICAgICROcmVzdWx0ID0gcG93KCROeCwgJGkpOyAvLyBFcXVpdmF1dCDDoCBmYWlyZSAiTnggKiBOeCAqICIuLi4kaSBmb2lzIgogICAgJE5wb3dlciAqPSAkTnJlc3VsdDsKCWVjaG8gIiROeCByYWlzZWQgdG8gdGhlIHBvd2VyIG9mICROeSBlcXVhbHMgJE5wb3dlciI7CgllY2hvICJcbiI7Cn0=