2013-04-28 22 views
0

=>->之間的區別是什麼?當我應該使用這些?我知道 - >可以用在像$obj->foo=>這樣的對象中,是否有其他地方我們可以使用它們?在php中=>和 - >有什麼區別?

+3

[參考這是什麼符號這意味着在PHP](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – 2013-04-28 11:48:44

回答

1

正如chandresh所述但有例子:

=>是聯想數組。你會做這樣的:

$arr = array("key" => "value"); // now value can be access simply by typing $arr['key']; 

- >是訪問對象的屬性(變量)和方法(函數)

// instead of doing this: 
calculate(); 

// if you have created an object, you could access the method(function) like so: 

$object->calculate(); // to call method(function) inside a class\object 
+0

謝謝你...對你的幫助我真的很感謝 – 2013-04-28 12:31:00

+0

不客氣:) – 2013-04-28 12:44:56