问:hmm它没有声明它希望我调用它,或者设置一个return函数来调用它。但是我收到的错误轨道1不再过去了吗?这是{}个错误吗?
fish.php
<?php
类Fish { public $ common_name ; 公共$味; 公共$ record_weight ; 函数__construct ($ name ,$ flavor ,$ record ){ $ this- > common_name = $ name ; $ this- >风味= $ flavor ; $ this- > record_weight = $ record ; }公共函数getInfo (){ $ output =
“在{ $这- > COMMON_NAME }是一个真棒鱼。” ;
$输出。= “这是非常{ $这- >味}食用时。” ; $ output 。= “当前世界纪录{ $ this- > common_name }权衡{ $ this- > record_weight } 。” ; 返回$ output ; } }类鳟扩展鱼{公共$种;
函数 __construct ($ name , $ flavor , $ record , $ species ){
父:: __construct ($ name ,$ flavor ,$ record ); $ this- >种= $种; } } $ brook &95 =新鳟鱼(“鳟鱼” ,“美味” ,“ 14磅8盎司” ,“布鲁克” );?>
答:您创建的对象应命名为$ brook_trout。&95; 应该是下划线。