Re: How to force a variable to be a custom object?

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

 



Alex Gemmell wrote:
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.

I don't know if this works in PHP4, but I would suggest to clear this in your constructur. But I don't know if this is always called in PHP4.

class myClass {

	var $object;

	myClass() {
	
		$this->object = new OtherObject();

	}

}

This isn't really forced, since you could change $object from outside the class. If there is a way you should declare $object private. That's not stylish, but I guess it works.

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