PHP继承任务

创建程序以使用继承查找Triangle区域。

<?php
	classgetdata
	{
		public $h;
		public $b;
		public function method1()
		{
			$this->h= $_REQUEST['height'];
			$this->b= $_REQUEST['base'];
		}

	}
	classfindarea extends getdata
	{
		public $area;
		public function method2()
		{
			$this->area= ($this->h* $this->b)/2;
			echo "Area of Triangle is : ".$this->area;
		}
	}
	if(isset($_REQUEST['submit']))
	{
		$obj = new findarea();
		$obj->method1();
		$obj->method2();
	}

	
?>
<html>
<head>
</head>
<body>
	<form method= "post">
		<table align ="left" border="1">
		<tr>
			<td> Enter Height </td>
			<td><input type = "text" name="height"/></td>
		</tr>
		<tr>
			<td> Enter Base </td>
			<td><input type = "text" name="base"/></td>
		</tr>
		<tr>
			<td align ="center" colspan="2">
			<input type= "submit"name="submit"value="click"/>
		</td>
		</tr>
		</table>
		</form>
</body>
</html>

输出

PHP继承任务
PHP继承任务
PHP继承任务

来源:

https://www.srcmini02.com/29231.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37993.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?