我的代码的最后一行出了什么问题?

0 php oop error-handling function

以下代码适用于我的大学项目.当我作为网页运行时,最后一行有错误...我需要有关如何解决此问题的帮助.

<?php
include_once 'ShapeClass.php';    
class Square extends Shape
      print "<h2>This square's side is not bigger than the parallelogram's height</h2>";
   }
break;
}
?>
Run Code Online (Sandbox Code Playgroud)

Sha*_*ran 6

正确的方式..

<?php
include_once 'ShapeClass.php';

class Square extends Shape
{
    function __construct()
    {
                print("<h2>This square's side is not bigger than the parallelogram's height</h2>");
    }
}
Run Code Online (Sandbox Code Playgroud)

你犯的错误

  • 有一个不必要的break声明.
  • 你不能直接print在课堂上.您需要将其包装在方法中.
  • 你忘了打开{后您的class