Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
The only other solution that comes to mind is a little messy but it lets
you get away with no object. Instead of calling the method statically
you can use call_user_func_array() with the child class name as a
parameter.
Torsten, I also found the following link to be helpful. Check out the
user notes from michael at digitalgnosis dot removethis dot com (he did
something similar to what I have already suggested, i.e. call_user_func)
http://www.php.net/manual/en/language.oop5.static.php
Hi Jason,
thanks for
By tunnelling the call through Porsche's own drive() method
debug_backtrace() will contain two traces, one of them with the correct
class name.
I tried using reflection but reflecting car by using __CLASS__ doesn't
give any information about the classes that extend it. So this doesn't work
either.
Jason Barnett wrote:
Indeed! I was actually quite surprised that this wasn't the way
__CLASS__ resolved... I had to code it to believe it (and I didn't even
do that until after you told us __CLASS__ didn't work!)
I would like to thank all of those that cared about my problem and
tried to
darn, send button again!! (sent too early)
Jochem Maas wrote:
Jason Barnett wrote:
Indeed! I was actually quite surprised that this wasn't the way
__CLASS__ resolved... I had to code it to believe it (and I didn't
even do that until after you told us __CLASS__ didn't work!)
I would like to
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The backtrace doesn't see class b at all, all references to it have
vanished into thin air.
I spent days trying to solve this on my own until I happened upon this
thread - it appears
Morten Rønseth [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The backtrace doesn't see class b at all, all references to it have
vanished into thin air.
I spent days
Torsten Roehr wrote:
Morten Rønseth [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The backtrace doesn't see class b at all, all references to it have
vanished into thin air.
I
Because it's a change, that should be reverted, or documented.
didou
M. Sokolewicz wrote:
Torsten Roehr wrote:
Morten Rønseth [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The
Morten Rønseth wrote:
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The backtrace doesn't see class b at all, all references to it have
vanished into thin air.
as a side note - using a function like debug_backtrace() seems to be a
Mehdi Achour wrote:
Because it's a change, that should be reverted, or documented.
don't top post - its bad form and many people ignore topposts.
Mehdi is right to say that debug_backtrace() has changed - but so has
the whole engine - I don't think that function was ever meant to be used
in the
Jochem Maas wrote:
Morten Rønseth wrote:
Hi,
I just tried the example code at
http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3
The backtrace doesn't see class b at all, all references to it have
vanished into thin air.
as a side note - using a function like
Jochem Maas wrote:
Mehdi Achour wrote:
Because it's a change, that should be reverted, or documented.
don't top post - its bad form and many people ignore topposts.
Mehdi is right to say that debug_backtrace() has changed - but so has
the whole engine - I don't think that function was ever meant
try using __CLASS__
Torsten Roehr wrote:
Hi list,
in PHP4 it was possible to get the name of the calling class with
debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I
didn't find a solution in the archives.
Is there *any* way to get the name of the calling class?:
class Car
M. Sokolewicz wrote:
try using __CLASS__
Torsten Roehr wrote:
This is a good suggestion but I wonder... Torsten do you have a large
heirarchy of parent classes or just one parent? E.g. Car - Sports Car
- Porsche. More importantly will __CLASS__ resolve to the class name
that you need...
If
Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
M. Sokolewicz wrote:
try using __CLASS__
Torsten Roehr wrote:
This is a good suggestion but I wonder... Torsten do you have a large
heirarchy of parent classes or just one parent? E.g. Car - Sports Car
- Porsche.
__CLASS__ contains the name of the class the method is in. In my sample it
would be 'Car' and not 'Porsche'.
What I don't understand is why the behaviour of debug_backtrace() has been
changed!?!
Regards, Torsten
I have no idea why the behaviour changed (I didn't really use the
function before,
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
return get_class($this);
}
}
class Porshe {
}
$foo = new Porshe();
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
return get_class($this);
}
}
class Porshe {
}
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
return get_class($this);
}
}
class Porshe {
}
Daniel Schierbeck wrote:
Christopher Fulton wrote:
This should work for you then(maybe...i don't have php5 on my
system, so it may not, but i think it would.
http://us4.php.net/manual/en/function.get-class.php
class Car {
function drive() {
return get_class($this);
I was kinda thinking about all that too, for a project I'm currently
doing, in that I wanted to be able to create a singleton, without
having to put the singleton code in each class. The only hack I could
think of was to use debug_backtrace() to get the line of source that
contained the call, and
22 matches
Mail list logo