|
Posted by Alex Gemmell on 09/02/05 15:31
Hi all,
Just a quickie today: I was wondering if I can declare a Class variable
as a certain type of object. I'm using PHP 4 by the way.
For example, if my class looks like this:
class myClass {
var $object;
function someFunction() {
// code, code, code ....
}
}
Is there anyway I can limit the variable "$object" to be of a particular
Class of object that I have made. Something like:
class myClass {
var $object *type=myOtherClass*;
function someFunction() {
// code, code, code ....
}
}
Yes, yes, I know "*type=myOtherClass*" isn't PHP code, but do you see
what I'm getting at? How would I achieve this? Is it even possible?
And would I then also have to include/require the path to the
"myOtherClass" definition script in the myClass definition?
e.g.
class myClass {
*require_once('path/to/myOtherClass.php');*
var $object *type=myOtherClass*;
function someFunction() {
// code, code, code ....
}
}
Any ideas folks?
All the best,
Alex
Navigation:
[Reply to this message]
|