Jump to content

*SOLVED* What does "->" mean?


Cell0518

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
Link to comment
https://forums.phpfreaks.com/topic/4604-solved-what-does-mean/
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.
Link to comment
https://forums.phpfreaks.com/topic/4604-solved-what-does-mean/#findComment-16121
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.
Link to comment
https://forums.phpfreaks.com/topic/4604-solved-what-does-mean/#findComment-16128
Share on other sites

Archived

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

×
×
  • Create New...

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.