Re: Programming general question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 27, 2009 at 05:18:35PM -0600, Terion Miller wrote:

> I googled this and didn't find an answer ....
> my question is how do you know when to use an object or array
> 
> would an object just be 1 instance, and array is several things together ( I
> know infantile coder language I use..but I'm a baby still in this)
> 
> Can someone explain objects and arrays in plain speak for me?

An array is like in math, except that an array in PHP stores anything
you like. It's just a bunch of them together.

An object can also store a bunch of different things, but it also has
"methods", which are really just functions. An array won't actually *do*
anything; you have to do things *to* it. An object can actually do stuff
at your direction. Like:

$kitchen->make_coffee('cream', 'sugar');

The object here is $kitchen, and you've told it to use its make_coffee()
method, which does something or another. You can also make those
"methods" private so that code outside the object can't "see" them.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux