Hello Dan,

Friday, October 10, 2003, 9:10:23 AM, you wrote:

> PHP5 10/10/2003 CVS.

> Currently, I don't see an easy way of accessing the constants of a child
> class from a base class.
Use the child's class name:
php -r 'class t{static function f(){echo tt::c;}}class tt extends t{const 
c="Hello\n";} t::f();'

But i guess you want something dynamically as $class::const, right?

the next example uses 'self' which doesn't work because self is bound at
compile time:
php -r 'class t{function t(){echo self::c;}}class tt extends t{const c= "Hello\n";} 
$o=new tt;'

So you'd need something like '$this::c' which is impossible right now.

Funny thing is the following which returns NULL what makes absolute no sense
to me. It somehow looks like either the correct constant is used but it is
uninitialized or there is an error missing.
php -r 'class t{function t(){var_dump($this->c);}}class tt extends t{const c= 
"Hello\n";} $o=new tt;'

-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to