Re: Programming general question

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

 



On Wed, 2009-01-28 at 01:07 +0100, Edmund Hertle wrote:
> 2009/1/28 Terion Miller <webdev.terion@xxxxxxxxx>
> 
> > 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
> 
> 
> Hey,
> 
> Arrays: A structure to store data
> Example:
> $example = array("value1", "value2", "value3);
> echo $example[0]; // echos "value1"
> echo $example[2]; // echos "value3"
> 
> Object: Something totally diffrent. A object is an instance of a class.
> Contains variables and methods.
> 
> I don't know how you thought of using arrays or objects for the same
> problem? Can you give an example?

An array's functionality can be implemented as a Class with specific
array instances being Objects. This allows the array to be used in
polymorphic contexts and to be extended by subclasses. The same can be
said for any primitive datatype.

Personally, I haven't seen a need to use an Array class in PHP. That's
not to say it doesn't have a purpose, but I lean towards primitives when
possible for efficiency.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
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