-3

Possible Duplicate:
In, PHP, what is the "->" operator called and how do you say it when reading code out loud?

This is the second question I've asked about the following tutorial:

http://www.allsyntax.com/tutorials/PHP/24/Building-a-Comments-Script/2.php

I'm very new to PHP / MySQL so I'm just trying to get familiar with it. I need to know what the arrows mean / do in the second code-box down the page...

e.g.

"'.htmlspecialchars(stripslashes($info2->subject)).'"

(The arrow between $info2 and subject).

Community
  • 1
  • 1
Dan
  • 65
  • 2
  • 8

3 Answers3

1

The arrow means that subject is a member variable of the object represented by $info2. The arrow -> is object notation. Array notation would be $info2['subject'] for comparison.

voncox
  • 1,191
  • 7
  • 13
  • Thanks for the comparison with array notation - that's something I've been over. I'm not familiar with objects. – Dan Aug 09 '11 at 13:41
1

The arrow is used to access a member of an object instance(This holds since PHP5). Prior to PHP5 it was also possible to access static members of a class.

There is a good explanation here: http://www.php.net/manual/en/language.oop5.references.php

fyr
  • 20,227
  • 7
  • 37
  • 53
0

-> is the object operator.

Buy yourself a good PHP book. Stack Overflow is not a tutorial, and web tutorials will not teach you PHP properly.

Also, keep the PHP manual bookmarked. Ensure that you have read it, all, at least three times before asking further questions about PHP syntax here.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • I've already ordered one - I'm just looking up tuts in the meantime. I'll look through the PHP manual. I'd gone through the operators through a tutorial somewhere but this one wasn't mentioned. – Dan Aug 09 '11 at 13:40
  • @Dan: Put the "tuts" down. They will lead you astray. Go do something else until your book arrives. :) – Lightness Races in Orbit Aug 09 '11 at 13:54