Re: Constant Scope PHP5

From: Date: Sat, 23 Aug 2003 18:20:11 +0000
Subject: Re: Constant Scope PHP5
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-4146@lists.php.net to get a copy of this message
Yes, there appears to be some inconsistency here. We'll look into it. Zeev At 21:14 23/08/2003, Brad Bulger wrote:
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); ?>
Output: no it's not yes it's bar
Zeev Suraski wrote:
At 14:35 22/08/2003, Arjen Brouwer wrote:
Should'nt this work? Currently it reports an error about a undefined constant. <? class Test {
    const FOO = 100;
    var $bar = FOO;
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. Zeev
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#4146) next »