Forum Moderators: coopster
It confused me too when I first started looking at php.
Here's some further reading on classes
[php.net...]
[sitepoint.com...]
Tim
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?
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.
$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. :)