php中static静态变量的使用

user_name=$user_name;
  echo $user_name.\"加入游戏\".\"
\"; } //创建静态函数,每个人充值的费用 static function join_game($user_money){ self::$user_money+=$user_money; } //返回静态函数 static function return_join_game(){ return self::$user_money; } public function user_age($user_age){ $this->user_age=$user_age; if($user_age<18){ echo \"对不起\".$this->user_name.\"您还未满十八周岁无法加入游戏哦!\".\"
\"; } else{ echo $this->user_name=$user_name.\"祝您游戏愉快哦!\".\"
\"; } } //统计当前在线的人数 public static function total(){ self::$number+=1; } //返回当前统计函数 public static function return_total(){ return self::$number; } } //创建人物 $user1=new child(\"张三\"); //调用人物充值函数 child::join_game(600); //创建人物的年龄 $user1->user_age=33; //判断人物的年龄 $user1->user_age(33); //统计当前的人数函数 child::total(); //创建人物 $user2=new child(\"李四\"); //调用人物充值函数 child::join_game(500); //创建人物的年龄 $user2->user_age=16; //判断人物的年龄 $user2->user_age(16); //统计当前的人数函数 child::total(); //创建人物 $user3=new child(\"王五\"); //调用人物充值函数 child::join_game(400); //创建人物的年龄 $user1->user_age=25; //判断人物的年龄 $user1->user_age(25); //统计当前的人数函数 child::total(); //调用静态函数,充值费用 echo \"一共充值了\".child::return_join_game().\"元\".\"
\"; //调用当前在线人数 echo \"当前在线人数为:\".child::return_total().\"人\".\"
\"; ?>

你可能感兴趣的:(PHP,前端技术)