这段代码的最后一行怎么了?

时间:2014-03-17 05:30:35

标签: php html

这是关闭php的最后一行的代码有一个我似乎无法找到的错误。该代码适用于我的大学项目。开放的php括号很好但是在第27行似乎是代码本身有错误。

<?php
include_once 'ShapeClass.php';

class Circle extends Shape
{
    private $radius;

    function __construct($n,$c,$r)
{
    parent::__construct($n,$c);
    $this->radius = $r;
}


public function area()
{
    return ( pi()*$this->radius * $this->radius);
}

public function perimeter()
{
    return ( 2 * pi() * $this->radius);
}

public function compareParameters($s)
    {
    case "Circle":
    }
        {if ($this->radius > $r->radius)
            {
                print "<h2>This circle's radius is bigger</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger</h2>";
            }
        break;
        }
    case "Square":
        {if ($this->radius > $s->side)
            {
                print "<h2>This circle's radius is bigger than the square's side</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the square's side</h2>" ;
            }
        break;
        }
    case "Rectangle":
        {if ($this->radius > $w->width)
            {
                print "<h2>This circle's radius is bigger then the rectangle's width</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the rectangle's width</h2>" ;
            }
        break;
        }
    case "Rectangle":
        {if ($this->radius > $h->height)
            {
                print "<h2>This circle's radius is bigger than the rectangle's height</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the rectangle's height</h2>";
            }
        break;
        }
    case "Triangle":
        {if ($this->radius > $b->base)
            {
                print "<h2>This circle's radius is bigger than the triangle's base</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the triangle's base</h2>" ;
            }
        break;
        }
    case "Triangle":
        {if ($this->radius > $ha->height)
            {
                print "<h2>This circle's radius is bigger than the triangle's height</h2>";
            }
         else
            {
                print "<h2>This circles radius is not bigger than the triangle's height</h2>";
            }
        break;
        }   
    case "Triangle":
        {if ($this->radius > $hb->hypotenuse)
            {
                print "<h2>This circle's radius is bigger than the triangle's hypotenuse</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the triangle's hypotenuse</h2>" ;
            }
        break;
        }
    case "Parallelogram":
        {if ($this->radius > $sb->sidebase)
            {
                print "<h2>This circle's radius is bigger than the parallelogram's base</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the parallelogram's base</h2>";
            }
        break;
        }
    case "Parallelogram":   
        {if ($this->radius > $sh->sideheight)
            {
                print "<h2>This circle's radius is bigger than the parallelogram's height</h2>";
            }
         else
            {
                print "<h2>This circle's radius is not bigger than the parallelogram's height</h2>";
            }
        break;
                }
?>

1 个答案:

答案 0 :(得分:2)

您有case个案例,但周围没有switch

检查http://www.php.net/manual/en/control-structures.switch.php

看起来应该有点像:

switch (...) {
    case "..." {
        ...
        break;
    }
    case "..." {
        ...
        break;
    }
    case "..." {
        ...
        break;
    }
    case "..." {
        ...
        break;
    }
    default: {
        ...
        break;
    }
}

{} / case语句中的default是可选的 default语句也是可选的。