以下のコードを実行すると、次の行にエラーが発生しましたecho $attribute;
。エラーコード:「キャッチ可能な致命的なエラー:クラスSomeShapeのオブジェクトを文字列に変換できませんでした」:このコードの何が問題になっていますか?ありがとう。
<?php
class Shape
{
static public $width;
static public $height;
}
class SomeShape extends Shape
{
public function __construct()
{
$test=self::$width * self::$height;
echo $test;
return $test;
}
}
class SomeShape1 extends Shape
{
public function __construct()
{
return self::$height * self::$width * .5;
}
}
Shape::$width=60;
Shape::$height=5;
echo Shape::$height;
$attribute = new SomeShape;
echo $attribute;
$attribute1 = new SomeShape1;
echo $attribute1;
?>