Re: Constant Scope PHP5
| From: | Brad Bulger | Date: | Sat, 23 Aug 2003 18:14:49 +0000 |
| Subject: | Re: Constant Scope PHP5 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4144@lists.php.net to get a copy of this message | ||
hmm. but you can reference class constants without class/self::
when creating futher constants ('const bla = foo << 1;')
and this works, too:
<?php
class foo
{
const bar = 3;
function bla($x)
{
if ($x === bar)
print "yes it's bar\n";
else
print "no it's not\n";
}
}
$x = new foo;
$x->bla(4);
$x->bla(3);
?>
Zeev Suraski wrote:Output: no it's not yes it's bar
At 14:35 22/08/2003, Arjen Brouwer wrote:Should'nt this work? Currently it reports an error about a undefined constant. <? class Test {Should be var $bar = Test::FOO (or self::FOO, even though it appears not to work right now) - there's no implicit class/object dereference of any kind in PHP. Zeevconst FOO = 100; var $bar = FOO;