Welcome to the Treehouse Community
Looking to learn something new?
Luke Lee7,577 Points
How to use -> and =>
I have seen these 2 codes a lot in php files. What's the difference?
'href' => $this->url->link('common/home'), if (isset($this->request->get['path'])) $data = array( 'filter_category_id' => $category_id, 'filter_filter' => $filter, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit );
The -> is used to access properties and methods that are part of an Object in PHP.
In your example the $this variable is an object which contains the objects url and request.
The url object contains a function (considered a method when within an object) of link. The request object contains a variable (considered a property when within an object) of get which just so happens to be associative array which contains the variable 'path'.
The => is as far as I know only used to identify a key to a value in an associative array as shown in your example.
Hope that helps?