不在类定义里赋值可以这么写
<?php
class NbaPlayer{
public $name;
public $height;
public $weight;
public $team;
public $playerNumber;
public function run(){
echo "Running\n";
}
public function jump(){
echo "Jumping\n";
}
public function dribble(){
echo "Dribbling\n";
}
public function shoot(){
echo "Shooting\n";
}
public function dunk(){
echo "Dunking\n";
}
public function pass(){
echo "Passinging\n";
}
}
$jordan = new NbaPlayer();
$jordan->name="Jordan";
$jordan->height="198cm";
$jordan->weight="92kg";
$jordan->team="Bull";
$jordan->playerNumber="23";
echo $jordan->name."\n";
?>