qq_Jonathan丶Cle_0
2015-12-02 15:11
<?php
date_default_timezone_set("PRC")
class Human{
public $name;
public $height;
public $weight;
public function eat($food){
echo this->name."'s eating ".$food."\n";
}
}
class NbaPlayer extends Human{
public $team="Bull";
public $playerNumber="23";
function __construct($name, $height, $weight, $team, $playerNumber){
$this->name=$name;
$this->height=$height;
$this->weight=$weight;
}
function __destruct(){
echo "Destroying".$this->name."\n";
}
public function run(){
echo "Running\n";
}
public function jump(){
echo "jumping\n";
}
public function dribble(){
echo "Dribbling\n";
}
$jordan=new NbaPlayer("Jordan","198cm","98kg","Bull","23");
echo $jordan->name."\n";
$jordan->eat("Apple");
}
?>
网页提示 错误 Parse error: syntax error, unexpected 'class' (T_CLASS) in F:\Demo\test.php on line 3
一般出错时,要在error line 的前后行找一找,基本上就能找到error了!
date_default_timezone_set("PRC");
少个分号!
这个大括号位置错了,应该放在Human类后面而不是全部括起来
解析错误:语法错误,出乎意料的“类”(T类)F:\ Demo \测试。在第3行
找个翻译工具,翻译着看
PHP面向对象编程
70146 学习 · 361 问题
相似问题