Jump to content

Archived

This topic is now archived and is closed to further replies.

Cell0518

*SOLVED* What does "->" mean?

Recommended Posts

Example (from Gallery 2)

$urlGenerator->makeUrl($path));


for this "->", does it mean something like this?
$variable "execute and set return value = to $variable" makeURL(to "$path variable" in this case)?

Just trying to understand some of the more complicated code in Gallery.

Thanks,
Chris

Share this post


Link to post
Share on other sites
sit and read some articls for Object Oriented Programing (OOP) and u'll see what it means

Share this post


Link to post
Share on other sites
[!--quoteo(post=353605:date=Mar 10 2006, 08:11 AM:name=Cell0518)--][div class=\'quotetop\']QUOTE(Cell0518 @ Mar 10 2006, 08:11 AM) [snapback]353605[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Example (from Gallery 2)

$urlGenerator->makeUrl($path));
for this "->", does it mean something like this?
$variable "execute and set return value = to $variable" makeURL(to "$path variable" in this case)?

Just trying to understand some of the more complicated code in Gallery.

Thanks,
Chris
[/quote]

$urlGenerator is an object, makeUrl is a method for that object. It's basically calling the makeUrl method with an argument of $path.

It doesn't appear that this is returning anything as there's no additional variable. It may be that the method creates the URL and stores it in an internal member variable.

Share this post


Link to post
Share on other sites
i'll try to break it down a little simpler... although what was said above is correct. basically, the "->" operator simply refers to a member of an object. whether that member is a function or a variable, you refer to it with this operator. for instance, if i create a simple class and want to access the member variables, i would use that operator as well (within the class, it's used with the special key variable $this):
[code]
class User {
  var $name;
  var $nickname;
  
  function User($user, $nick) {
    $this->name = $user;
    $this->nickname = $nick;
  }

  function greet() {
    echo "Hello, $this->nickname!";
  }
}

$me = new User("me", "obsidian");
$me->greet();
[/code]

notice that my object is simply referencing its member function "greet()". hope this helps.

Share this post


Link to post
Share on other sites
Thanks all,

I used an example from an article, and it makes sense.

Thanks again,
Chris

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.