Sum of two numbers without using + operator in PHP

Home > PHP Reference > Sum of two numbers without using + operator in PHP



Sum of two numbers without using + operator in PHP

Get the value inputted by users in first text box and second text box. in for loop number of condition is defined till first number and increment the second number one by one till the condition. display the second number

PHP script

<?php 
	if(isset($_REQUEST['add']))
	{
	$f=$_REQUEST['f'];
	$s=$_REQUEST['s'];
		for($i=1;$i<=$f;$i++)
		{
		 $s++;		
		}
		echo "<font color='blue'>Sum of two number=".$s."</font>";
	}
?>

HTML Script

<html>
	<head>

		<title>Sum of two number without using "+" operator Table</title>
		<style>
			input{width:180px; height:35px}
		</style>
	</head>

	<body>
		<form method="post">
			<table border="1" width="350px">
				<tr>
					<td>Enter first number </td>
					<td><input type="text" name="f"/></td>
				</tr>
				<tr>
					<td>Enter second number </td>
					<td><input type="text" name="s"/></td>
				</tr>
				<tr>
					<td colspan="2" align="center">
					<input type="submit" value="+" name="add"/>
					</td>
				</tr>
			</table>
		</form>	
	</body>
</html>
sumoftwonumber