class variables and methods

From: Date: Sun, 19 Aug 2001 02:09:08 +0000
Subject: class variables and methods
Groups: php.general 
Request: Send a blank email to php-general+get-63303@lists.php.net to get a copy of this message
I've been doing some reading up on OOP in PHP, and looking at some of the classes available on the web, and I've got what is probably a stupid question. I've seen this many many times.. class someclass { var $somevar = "someval"; function set( $key, $val ) { $this->$key = $val; } } $myClass = new someclass; $myClass->set( "somevar", "someotherval" ); why write a set method when you can just as easily call $myClass->somevar = "someotherval"; Is there a reason for this? Also, alot of the different table classes (an OOP approach to HTML tables) stores the data in arrays, but at what point is it too much to store into an array? Say you have a forum and the text entered for a single respone could be quite lengthy, much less for 100 replies... wouldn't that be a bit much to store into an array? I know it depends on the system resources, but is there a practical limit that people follow?

« previous php.general (#63303) next »