Re: Mixing classes

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

 



Thomas Goyne wrote:
On Wed, 20 Oct 2004 08:09:53 +0300, Tomi Kaistila <tomi.kaistila@xxxxxxxxxxxx> wrote:

Hi!

A good idea, which I have used for some classes, like the Journal class (error handling) which fits in with the Core class. Unfortunantly I have too many classes to make them all into a chain of child classes. And also I have an ambition to write these classes in sorta seperate tools, which I can then use in other projects with no altering of the code.

The database (mysql) class is such a class, which is in use in almost every project I work at.

Would it be possible to create a member variable to a class on the fly, without specifically creating it when you write the class? Something like this:

<?php
class MyClass {
     var $MemberVar1 = "";
     var $MemberVar1 = "";

function MyClass() {
     //constructor
}
function MkMemVar($newmemvar, $memvarval) {
     $this->newmemvar = $memvarval;
     // this is just an example, don't know it would actually be done so
     // but you get the idea: the $newmemvar would be the name of the new
     // member variable and $memvarval would be the value for the new
     // member variable.
}
?>

possible.

Or could it even be possible to do this outside of a class? So that I
yes, that is possible.

wouldn't have to specify a seperate function for it in my classes?


This way I could make an instance of another class inside any class on the need-bases and it would solve my problem. Is there anyway to accomplish this? I couldn't find any immediately solution by looking at the php manual, but it doesn't mean it's not there.




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