Voting

: max(four, five)?
(Example: nine)

The Note You're Voting On

luke at liveoakinteractive dot com
18 years ago
This note is a response to the earlier post by davidc at php dot net. Unfortunately, the solution posted for getting the class name from a static method does not work with inherited classes.

Observe the following:
<?php
class BooBoof {
public static function
getclass() {
return
__CLASS__;
}

public function
retrieve_class() {
return
get_class($this);
}
}

class
CooCoof extends BooBoof {
}

echo
CooCoof::getclass();
// outputs BooBoof

$coocoof = new CooCoof;
echo
$coocoof->retrieve_class();
// outputs CooCoof
?>

__CLASS__ and get_class($this) do not work the same way with inherited classes. I have been thus far unable to determine a reliable way to get the actual class from a static method.

<< Back to user notes page

To Top