Heim  >  Artikel  >  php教程  >  求大哥们看看这计算器

求大哥们看看这计算器

WBOY
WBOYOriginal
2016-06-06 19:37:211076Durchsuche

刚刚学编程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>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn