Reply to How to force a variable to be a custom object?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация