note 94953 modified in function.defined by danbrown

From: Date: Fri, 04 Dec 2009 14:56:30 +0000
Subject: note 94953 modified in function.defined by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163573@lists.php.net to get a copy of this message
You can use the late static command "static::" withing defined as well. This example outputs - as expected - "int (2)" <?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()); ?> --was-- <?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)" http://php.net/manual/en/function.defined.php

« previous php.notes (#163573) next »