<?php
<?
if($_POST['calc']) {
//call function
$avg = trial($_POST['num1'], $_POST['num2']);
//display output
echo("The average is:" . $avg . "<br>");
} else {
// display form to get input
?>
<html>
<head>
<title></title>
</head>
<body>
<form name="form1" method="post" action="">
Enter first number
<input type="text" name="num1" id="num1">
<br>
Enter second number
<input type="text" name="num2" id="num2">
<br>
<input type="submit" name="calc" id="calc" value="Submit">
</form>
<br><br>
</body>
</html>
<? } // end if else ?>
<?
//******program-defined functions*****
function trial($fnum1, $fnum2) {
//calculates and returns an average
$calcavg = 0;
$calcavg = ($fnum1 + $fnum2) / 2;
return $calcavg;
}
?>
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.32
- Parse error: syntax error, unexpected '<' in /in/TcM7T on line 2
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '<' in /in/TcM7T on line 2
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/TcM7T on line 2
Process exited with code 255.
preferences:
192.04 ms | 1395 KiB | 123 Q