I am a newbie trying to learn some PHP . I have been studying others code and I keep coming across what appears to be operators I do not recognize. There are 2 in particular that keep appearing. They are "->" and "=>".
Examples of the code.
$Test->setTest($myname);
(I could not find the code snippet of the other 'operator'. =>)
Can anyone help?
Thanks
Whay is ->
Moderator: General Moderators
Re: Whay is ->
-> is an operator used with objects. In your example, $Test is an object, that has a setTest() method.
=> is used with arrays. Off the top of my head, I can only recall it used in two place, when iterating through arrays in a foreach(), and when creating arrays:
In both cases, the => is used to denote the value associated with a key in an array.
=> is used with arrays. Off the top of my head, I can only recall it used in two place, when iterating through arrays in a foreach(), and when creating arrays:
Code: Select all
foreach($foo as $key=>$value)
{
//do something
}
$myArray = array(
'one'=>1,
'two'=>2
);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Whay is ->
Thank you Pickle.. I finally found a 'object operator' tutorial once you pointed me in the right direction. I had gone completely though the standard PHP tutorial but no luck.
Thanks again.
Thanks again.