Simple triangle and rectangular perimeter area calculator implemented by PHP

Source: Internet
Author: User
This article mainly introduces the simple triangle and rectangular perimeter area calculator implemented by PHP. The implementation in this article is relatively simple and provides code file download. For more information, see

This article mainly introduces the simple triangle and rectangular perimeter area calculator implemented by PHP. The implementation in this article is relatively simple and provides code file download. For more information, see

Use PHP object-oriented knowledge to design a graphical calculator and abstract class knowledge. This calculator can calculate the circumference and area of a triangle and the circumference and area of a rectangle. This graphic calculator has four pages: 1. PHP graphical calculator home page index. php; 2. shape abstract class shape. class. php; 3. triangle calculation class triangle. class. php; 4. rect for Rectangle calculation. class. php.

PHP graphics calculator code click to download: PHP graphics calculator. Zip

The Code is as follows:

PHP graphical calculator Home Page:

Simple graphic calculator

Simple graphical calculator rectangle | triangle
<? Php error_reporting (E_ALL &~ E_NOTICE); // sets the class file function _ autoload ($ classname) {include strtolower ($ classname) required to automatically load this program ). ". class. php ";} // determines whether the user has selected to click a shape link if (! Empty ($ _ GET ['action']) {// Step 1: Create a shape object $ classname = ucfirst ($ _ GET ['action']); $ shape = new $ classname ($ _ POST); // Step 2: Call the interface view () $ shape-> view () in the shape object; // Step 3: whether the user submitted the form if (isset ($ _ POST ['dosubmit ']) {// Step 4: Check whether the user output data is correct, if ($ shape-> yan ($ _ POST) {// calculate the circumference and area of the image echo $ shape-> name. "perimeter :". $ shape-> zhou ()."
"; Echo $ shape-> name." area: ". $ shape-> area ()."
";}}// If the user does not click the link, the main program is accessed by default.} else {echo" select a graph to calculate!
";}?>

Abstract class of shape:

Abstract class Shape {// Shape name public $ name; // Shape calculation area method abstract function area (); // Shape calculation perimeter method abstract function zhou (); // shape graphical form interface abstract function view (); // shape verification method abstract function yan ($ arr );}

Triangle computing files:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.