How to force a variable to be a custom object?

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

 



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

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