Return to Snippet

Revision: 44233
at April 8, 2011 05:13 by JonnySnip3r


Initial Code
<?php

if(isset($_POST['sum1']) && isset($_POST['sum2']))
{
	$sum1 = $_POST['sum1'];
	$sum2 = $_POST['sum2'];
	
	function add($sum1,$sum2)
	{
		$answer = $sum1 + $sum2;
		
		if(!is_numeric($sum1) || !is_numeric($sum2))
		{
			return 'Please enter a number nob!';
		}
		
		echo $sum1 . ' + ' . $sum2 . ' = ' . $answer;
	}	
	
	echo add($sum1,$sum2);
}

?>

<form method="post" action="#">
	<input type="text" name="sum1" value="" /><br />
	<input type="text" name="sum2" value="" /><br />
	
	<input type="submit" name="submit" value="Add" />
</form>

Initial URL

                                

Initial Description
Very basic dont judge!

Initial Title
Simple addition function is php

Initial Tags
php, simple, function

Initial Language
PHP