PHP学习实例—2(简易图形计算器)

本文将介绍如何使用PHP创建一个简易的图形计算器,通过实例代码解析PHP在图形界面交互和数学运算中的应用,帮助初学者理解PHP在图形计算中的基本操作。
摘要由CSDN通过智能技术生成

主函数: index.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>图形计算器</title>
<style>
  * {
		margin: 0px;
		padding: 0px;
	}
	#contains {
	  width: 500px;
		margin: 20px auto;
		background: #0C0;
		text-align: center;
		
	}
	h1 {
	  width: 500px;
		height: 60px;
	}
	a {
	  font-size: 20px;
		text-decoration: none;
	}
	
	#footer {
	  width: 300px;
		background: #fff;
		margin: 0 auto;
		padding: 5px 10px;
		border-radius: 150px;
	}
</style>
</head>

<body>
	<div id="contains">
	  <h1>简易图形计算器</h1>
		<a href='index.php?action=rect'>矩形</a> |
		<a href='index.php?action=triangle'>三角形</a>|
		<a href='index.php?action=cirle'>圆形</a> 
		<hr>
 
	<?php
	  ini_set("display_errors", "On"); //开启错误调试
		//设置错误报告的级别,除了无关紧要的'注意',其他的报告都输出
		error_reporting(E_ALL & ~E_NOTICE);
		
		function __autoload($classname) { //魔术方法 自动加载类
		  include strtolower($classname).".class.php"; //将类名转化成小写
		}
	//	include "shape.class.php";
	//	include "rect.class.php";
    if (!empty($_GET['action'])) {
		//	echo "传送成功";
			$classname = ucfirst($_GET['action']);
			$shape = new $classname($_POST);
			$shape->view($_POST);
	
			if (isset($_POST['sub'])) {
				echo "<div id='footer'>";
				i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值