Jump to content


Photo

*SOLVED* What does "->" mean?


  • Please log in to reply
4 replies to this topic

#1 Cell0518

Cell0518
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationUSA / Japan (US Navy)

Posted 10 March 2006 - 01:11 PM

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
Chris

#2 naskoo

naskoo
  • Members
  • PipPip
  • Member
  • 13 posts
  • LocationBulgaria

Posted 10 March 2006 - 01:48 PM

sit and read some articls for Object Oriented Programing (OOP) and u'll see what it means

#3 XenoPhage

XenoPhage
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 10 March 2006 - 01:48 PM

[!--quoteo(post=353605:date=Mar 10 2006, 08:11 AM:name=Cell0518)--][div class=\'quotetop\']QUOTE(Cell0518 @ Mar 10 2006, 08:11 AM) View Post[/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.
--
[a href=\"http://blog.godshell.com\" target=\"_blank\"]XenoPhage[/a]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.[/quote]

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 March 2006 - 02:18 PM

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):
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();

notice that my object is simply referencing its member function "greet()". hope this helps.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 Cell0518

Cell0518
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationUSA / Japan (US Navy)

Posted 10 March 2006 - 09:37 PM

Thanks all,

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

Thanks again,
Chris
Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users