add more interesting PHP example code

This commit is contained in:
Fabian Jakobs 2010-12-17 09:31:42 +01:00
commit f99499bac3

View file

@ -159,7 +159,21 @@ for i in sys.argv[1:]:
<script type="text/editor" id="phptext"><?php
phpinfo();
function nfact($n) {
if ($n == 0) {
return 1;
}
else {
return $n * nfact($n - 1);
}
}
echo "\n\nPlease enter a whole number ... ";
$num = trim(fgets(STDIN));
// ===== PROCESS - Determing the factorial of the input number =====
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
echo $output;
?></script>