Classes / Collections

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
uruba_uk
Forum Newbie
Posts: 3
Joined: Tue Sep 05, 2006 2:04 pm

Classes / Collections

Post by uruba_uk »

Coming from a VB/ASP background I am used to classes and collection objects. Can this be achieved with PHP?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

PHP certainly has classes. As for collections, the place to start is with PHP arrays which are hashes and have a large library of functions that operate on them. In PHP5 there is the SPL library that adds some classes in this category. And due to the power of PHP's hashes and supporting library you can easily create specific collection classes to do anything you need to do. If you are using PHP5, you might want to look at the __get()/__set() methods for accessors, and SPL for functionalty like array access and iteratable.
(#10850)
uruba_uk
Forum Newbie
Posts: 3
Joined: Tue Sep 05, 2006 2:04 pm

Post by uruba_uk »

Thanks for the reply :)

So an array in PHP is actually an object with its own functions? (similar to arrays in .NET?)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

No, they are not objects.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

uruba_uk wrote:So an array in PHP is actually an object with its own functions? (similar to arrays in .NET?)
Please check the manual.

Array functions

Standard Library Objects
(#10850)
Post Reply