|
Posted by NC on 09/12/07 22:45
On Sep 12, 10:03 am, PaowZ <gpa...@gmail.com> wrote:
>
> $myVar = new MyClass(); //the var I want to be available to OtherClass
> ...
> ...
> class OtherClass{
> private $otherVar = $myVar; //seems to not work
> ..}
But of course. The scope of $myVar is lies outside OtherClass, so
$myVar is meaningless in the context of OtherClass.
> ..and I wish to initialize $otherVar 'as is', I mean,
> without having to pass arg through __construct().
And I wish to build a perpetual motion machine. Alas, the world does
not work that way...
> The way I tried above doesnt seem to work, unlike it would
> be in a function..
It wouldn't work in a function either, unless you declare $myVar as
global.
> any idea ??
Don't let your wishes control you; control your wishes instead.
Cheers,
NC
Navigation:
[Reply to this message]
|