Forum Moderators: coopster

Message Too Old, No Replies

what does -> mean?

         

someone

5:47 pm on Oct 28, 2004 (gmt 0)

10+ Year Member



for example, $table->display();

i get confused when i see arrows like that, would someone please explain to me what the arrow is used for? thanks.

jatar_k

6:33 pm on Oct 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



it is called the member selection operator

When using a pointer to a class or structure, you use the member selection operator, or ->, to access member data and functions:

Timotheos

7:17 pm on Oct 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi someone,

It confused me too when I first started looking at php.

Here's some further reading on classes
[php.net...]
[sitepoint.com...]

Tim

AthlonInside

7:10 am on Oct 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is object oriented programming.

In VB, it look like

Car.Door
Car.Mirror
Car.Belt

in PHP they look like

Car->Door
Car->Mirror
Car->Belt

And you can also have members fuction.

Car->PowerOn()
Car->Break()
Car->Accelerate()

Pretty fun stuff. But honestly how many PHP programmers are using Object Oriented Programming?

Code Sentinel

7:17 am on Oct 29, 2004 (gmt 0)

10+ Year Member



has to do with object oriented php, it's basically a function within a class that has been instantiated as an object.

every object has the variables and functions defined in the class used.

if you have a class named "Tables" with a function to create tables such as CreateTable($rows, $columns) then you can do something like

$obj = new Table;
$obj->CreateTable(3, 4);

and it will create your table within $obj which you then need to retrieve with another function in the object class that returns the data.

that's the best way I can explain it, still new to php OO myself and while it sounds great I still can't get it right.. I keep falling into the procedural method of putting things together.

dreamcatcher

9:03 am on Oct 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its also used in an sql query when you use mysql_fetch_object().

$query = "select rowname from blah where id = '$whatever' limit 1";
$row = mysql_fetch_object($query);

echo $row->rowname;

But honestly how many PHP programmers are using Object Oriented Programming?

I must admit, I like to use classes because they keeps things nice and neat. I can also use that same class in different programs, so it does come in handy. :)