Home >php教程 >php手册 >求大哥们看看这计算器

求大哥们看看这计算器

WBOY
WBOYOriginal
2016-06-06 19:37:211152browse

刚刚学编程PHP就是计算过后输出不了结果点计算后像还原了 无 ?phperror_reporting(E_ALL ~E_NOTICE);if( isset($_POST['sub']) ){$sum="";switch($_POST['ysf']){ case '+' : $sum=$_POST['num1'] + $_POST['num2'];break;case '-' : $sum=$_POST['num1'] - $

刚刚学编程 PHP 就是计算过后输出不了结果 点计算后像还原了
<?php
	error_reporting(E_ALL & ~E_NOTICE);
	if( isset($_POST['sub']) )
	{
		$sum="";
		switch($_POST['ysf'])
		{ 
		
		case '+' : $sum=$_POST['num1'] + $_POST['num2'];break;

		case '-' : $sum=$_POST['num1'] - $_POST['num2'];break;

		case '*' : $sum=$_POST['num1'] * $_POST['num2'];break;

		case '/' : $sum=$_POST['num1'] / $_POST['num2'];break;

		case '%' : $sum=$_POST['num1'] % $_POST['num2'];break;

		}
	}	
		echo '<br>';
?>




<HTML>
	<HEAD>
		<title>简单计算器</title>
	</HEAD>
	<body>
		<table horder="0" width="400" align="center">
		<form action="JSQ.PHP" meyhod="post">
			<caption><h1>简单计算器</h1></caption>

			<tr>

				<td>
					<input type="text" size="5" name="num1" value="" /><br>
				</td>
				
				<td>
					<select type="text" name="ysf">
						<option value="+"> + </option>
						<option value="-"> - </option>	
						<option value="x"> x </option>
						<option value="/"> / </option>
						<option value="%"> % </option>
					</select>
					
				</td>

				<td>
					<input type="text" size="5" name="num2" value="" /><br>
				</td>

				<td>
					<input type="submit" name="sub" value="计算">
				</td>

			<tr>
			<tr>
				<td colspan="4">
					<?php
						echo"计算结果 ={$sum} ";
					?>
				</td>
			</tr>
		</form>

		</table>

	</body>

</HTML>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn