note 74491 added to function.get-class
| From: | MarcW dot at osu1 dot php dot net | Date: | Fri, 13 Apr 2007 16:40:26 +0000 |
| Subject: | note 74491 added to function.get-class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125366@lists.php.net to get a copy of this message | ||
The previous comment (from matsgefvert dot se) is 100% correct. To further elaborate on the
persistence layers example suggested, consider the case where you are dynamically creating inherited
objects. For example:
<?php
class PersistedObject {
//...
public static function read($key){
//You will need the table name here to actually read
// from the persistence medium
echo get_class();
}
class SomeTable extends PersistedObject {
//...
}
/*
Somewhere else in our code we would like to call the read method
*/
$someTableObject = SomeTable::read(1234);
?>
Remember that the SomeTable class would be generated on the fly, probably by some DB schema. The
problem is that you would actually like the above example to output "SomeTable", but
unfortunately, it will output "PersistedObject".
----
Server IP: 69.147.83.197
Probable Submitter: 216.9.243.111
----
Manual Page -- http://www.php.net/manual/en/function.get-class.php
Edit -- https://master.php.net/note/edit/74491
Del: integrated -- https://master.php.net/note/delete/74491/integrated
Del: useless -- https://master.php.net/note/delete/74491/useless
Del: bad code -- https://master.php.net/note/delete/74491/bad+code
Del: spam -- https://master.php.net/note/delete/74491/spam
Del: non-english -- https://master.php.net/note/delete/74491/non-english
Del: in docs -- https://master.php.net/note/delete/74491/in+docs
Del: other reasons-- https://master.php.net/note/delete/74491
Reject -- https://master.php.net/note/reject/74491
Search -- https://master.php.net/manage/user-notes.php