3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.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.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.