note 75891 added to language.constants.predefined

From: Date: Wed, 20 Jun 2007 16:12:11 +0000
Subject: note 75891 added to language.constants.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-127831@lists.php.net to get a copy of this message
In response to stangelanda at gmail dot com, (who suggested a possible fix to get the actual class name of the object, when being called statically). in PHP5, this fix no longer works. Here is some example code: <?php function get_class_static() { $bt = debug_backtrace(); $name = $bt[1]['class']; return $name; } class foo { function printClassName() { print(get_class_static() . "<br>"); } } class bar extends foo { } $f = new foo(); $b = new bar(); $f->printClassName(); $b->printClassName(); ?> In PHP4, it outputs foo bar as you described. However, in PHP5, due to the way the debug_backtrace() function has been modified (see http://bugs.php.net/bug.php?id=30828) the output is now foo foo I have yet to figure out a way to get the original output in PHP5. Any suggestions would be very useful, and if I find an answer I'll post it here. ---- Server IP: 87.124.64.96 Probable Submitter: 85.210.211.75 ---- Manual Page -- http://www.php.net/manual/en/language.constants.predefined.php Edit -- https://master.php.net/note/edit/75891 Del: integrated -- https://master.php.net/note/delete/75891/integrated Del: useless -- https://master.php.net/note/delete/75891/useless Del: bad code -- https://master.php.net/note/delete/75891/bad+code Del: spam -- https://master.php.net/note/delete/75891/spam Del: non-english -- https://master.php.net/note/delete/75891/non-english Del: in docs -- https://master.php.net/note/delete/75891/in+docs Del: other reasons-- https://master.php.net/note/delete/75891 Reject -- https://master.php.net/note/reject/75891 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127831) next »