note 94953 added to function.defined
| From: | r dot hartung at roberthartung dot de | Date: | Fri, 04 Dec 2009 07:45:03 +0000 |
| Subject: | note 94953 added to function.defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163563@lists.php.net to get a copy of this message | ||
<?php
abstract class class1
{
public function getConst()
{
return defined('static::SOME_CONST') ? static::SOME_CONST : false;
}
}
final class class2 extends class1
{
const SOME_CONST = 2;
}
$class2 = new class2;
var_dump($class2->getConst());
?>
You can use the late static command "static::" withing defined as well. This example
outputs - as expected - "int (2)"
----
Server IP: 212.124.37.9
Probable Submitter: 77.21.39.35
----
Manual Page -- http://www.php.net/manual/en/function.defined.php
Edit -- https://master.php.net/note/edit/94953
Del: integrated -- https://master.php.net/note/delete/94953/integrated
Del: useless -- https://master.php.net/note/delete/94953/useless
Del: bad code -- https://master.php.net/note/delete/94953/bad+code
Del: spam -- https://master.php.net/note/delete/94953/spam
Del: non-english -- https://master.php.net/note/delete/94953/non-english
Del: in docs -- https://master.php.net/note/delete/94953/in+docs
Del: other reasons-- https://master.php.net/note/delete/94953
Reject -- https://master.php.net/note/reject/94953
Search -- https://master.php.net/manage/user-notes.php