Re: Programming general question
| From: | Ondrej Kulaty | Date: | Wed, 28 Jan 2009 09:54:52 +0000 |
| Subject: | Re: Programming general question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287266@lists.php.net to get a copy of this message | ||
Depends on what for you want to use that. Array is simple data structure, it
holds data, like variable, but objects has methods and properties, it acts
as someting which can do some sort of task and you access it via it's
interface (you call it's methods). You can use array for example to hold
result from database and than iterate it with for or foreach cycle. On the
other hand, object can be used for exaplme to send mail, you put into it
text body, mail adresses and so on and then call it's method send() which
causes mail to be send. The process of transforming data, generating headers
etc is completely done by the object and it's internal methods, you access
it only via it's well defined interface (it's methods you can call). Objects
are mainly used in OOP programming, where they cooperate together. Good way
to learn OOP is to learn something about design patterns...
--
"Terion Miller" <webdev.terion@gmail.com> píse v diskusním príspevku
news:37405f850901271518r21f5f73j44841e864de5c598@mail.gmail.com...
>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?
> Thanks
> Happy Coding
>