What is the '->' used for?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drewrockshard
Forum Commoner
Posts: 37
Joined: Sat May 29, 2004 6:07 pm
Location: Dallas, Texas
Contact:

What is the '->' used for?

Post by drewrockshard »

I have been doing some small php work and have been looking in to start designing web apps with php.

I want to start designing in OOP instead of just functions and variable, I want to start creating classes and more advanced coding.

I have see the following php code in alot of coding...but i really dont know what it means. The code looks like this:

Code: Select all

<?php
->
?>
Does it stand for assigning values to a certain variable?? I really havent found any docs on it so if you would please, clue me in on what it stands for in PHP so i can better understand. thank you
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Its how you refer to methods and attributes of a class.

Code: Select all

class Test {
   var $hello;

   function Test(){
      //blah
   }

   function set_text($string){
      $this->hello = $string;
   }
}

$myClass = new Test();   /Creates the class.
$myClass->set_text("Hello World!");   //calls the function
echo $myClass->hello;  //echos Hello World!
Post Reply