亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

代碼正常,為啥瀏覽器執行時,報警告: Notice: Undefined variable: fond in F:\Demo\class......

<?php?
class?Human{
		public?$name;
		public?$height;
		public?$weight;
		public?function?eat($food){
			echo?$this->name."'s?eating".$fond."<br>";
		}
		
	}
	
	class?NbaPlayer?extends?Human?{
		
		public?$team;
		public?$playerNumber;
		
		function?__construct($name,$height,$weight,$team,$playerNumber){
			
			//$this是php里面的偽變量,表示對象本身。
			//可以通過$this->的方式訪問對象的屬性和方法。
			$this->name?=?$name;
			$this->height?=?$height;
			$this->weight?=?$weight;
			$this->team?=?$team;
			$this->playerNumber?=?$playerNumber;
			
		}?
		
		public?function?run(){
			echo?"Running\n";
		}
		
		public?function?jump(){
			echo?"Jumping\n";
		}	
	}
	$player?=?new?NbaPlayer("Jordan","198cm","98kg","BUll","23");
		
		echo?$player->name."<br>";
		
		$player->eat("Apple");
		
?>

http://img1.sycdn.imooc.com//58f588470001592106520191.jpg

正在回答

2 回答

看清楚你第七行是什么,應該是$food,不是$fond



0 回復 有任何疑惑可以回復我~

哈哈,知道了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

代碼正常,為啥瀏覽器執行時,報警告: Notice: Undefined variable: fond in F:\Demo\class......

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號