Before anyone get's confused I thought I should note that $this won't work
because I need the name of the object for use _outside_ of the class itself
too.

For instance I have a group of about 30 functions in a seperate file which
directly modify $front_page. $front_page will now be inside of an object,
and I _could_ just change them to $pge->front_page, but here's the problem.

I'm doing all this so I can have variable function output. So for now I use
the object name $pge to output data, but in the future I may need to use
$xml or $pge_error. But I don't want to go through all the functions and
change the names, so I use a variable variable. But I don't know how to get
the variable variable name!

So what I want is to see what name $this is holding, then declare what comes
after $ as the value of a global variable which I will use in a variable
variable.


I know, I know, it's really complicated. But it really is the most
non-constraining way of going about it, as I'm probably going to use this
class many times in the future.

So I'm still stumped. Am I going to have to just use a hack-around till a
version of PHP includes such an odd class function, of which I know of know
other such existing function in any language? :(


--
Plutarck
Should be working on something...
...but forgot what it was.



""Plutarck"" <[EMAIL PROTECTED]> wrote in message
9c21ks$cp$[EMAIL PROTECTED]">news:9c21ks$cp$[EMAIL PROTECTED]...
> I've been using a function to output HTML to the user's browser, and now
my
> use has made it neccessary to put it all inside a class.
>
> All's going find and dandy and I've got it all working. However one of
it's
> variables is $front_page.
>
> Now in other pages there are references to $front_page, and I want to
change
> them to something like $objectname->front_pagee.
>
> The problem is that I can't know what the object will be named ahead of
> time!
>
> So my hack-around is in the class constructor I set a global variable
called
> $pge with the value submitted to the constructor. So someone would do
this:
>
> $somename = new Display(somename);
>
> But if someone typos the and the name of the variable is different from
the
> one submitted to the constructor, all the code will break! That's because
> I'm using a variable variable to refer to $front_page, like this:
>
> ${$pge}->front_page
>
> I told you it was a hack-around, and it isn't a good one.
>
>
> So is there ANY way to get the name of the object in PHP code without
> knowing the name of the object ahead of time?
>
> I'm really stumped!
>
>
>
> --
> Plutarck
> Should be working on something...
> ...but forgot what it was.
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to