jonpugh114 Posted July 7, 2011 Share Posted July 7, 2011 Hello, I'm trying to get into OOP and I'm putting together a class to create and validate form inputs/selects/textarea etc. The property I want to create is an array to hold errors. When a validation method fails to validate the posted input it will add an element to the array which is picked up by the method to create the input then add a class and an error message. What I'm stuck on is how to create a property as an array, and how to add elements to that array from within the class. Can anyone point me in the right direction? Maybe I should have started with "hello world"... Cheers, Jon Link to comment Share on other sites More sharing options...
Larry Posted July 11, 2011 Share Posted July 11, 2011 There's really nothing special here at all. Just treat it like any other array and treat it like any other property. Link to comment Share on other sites More sharing options...
Antonio Conte Posted July 12, 2011 Share Posted July 12, 2011 What he probably mean, Larry is that within classes, you cannot use $array[]. You have to use self::$array[] or classname::$array[] I know these things seem obvious for you, but a slow mind like mine took some time to remember to use this style. Link to comment Share on other sites More sharing options...
Recommended Posts