Understanding php syntax

Can someone please explain the symbols -> and => in the following code?

Any help appreciated.

if ($this->params->get(‘loadMootools’)) {
$this->_scripts = array_merge(array($template_baseurl . ‘/lib/js/mootools.js.php’ => ‘text/javascript’), $this->_scripts);
unset($this->_scripts[$this->baseurl . ‘/media/system/js/mootools.js’]);

-> is an object reference.

$this->_scripts[stuff] = "Go to the object $this, and find the _scripts property of it. In this case, that property is an array, and so it calls for a specific index of that array.
$this->params->get(‘loadMootools’) is actually "Go to the object $this, and find the params property of it. This property is apparantly an object itself, with a method get(), which is called with a string parameter (loadMootools)

=> is used as a key-value pairing identifier.

in this case, it’s in an array definition, assigning the value ‘text/javascript’ to the key $template_baseurl.‘/lib/js/mootools.js.php’. You also often see this notation in foreach statements (foreach ($array AS $key => $value))

-> is a class assignment:

=> is assigning a value to an index:

Edit: did not see the above post when I was replying. Much more detail provided.

Thanks Guys,

I think I’m starting half way up the ladder - need to go back to basics - thanks for the links :slight_smile: