Re: [PHP-DEV] Accessing child constants from base class

2003-10-11 Thread Marcus Börger
Hello Dan, Friday, October 10, 2003, 8:36:48 PM, you wrote: > On a side note, when an exception is thrown from inside the > __autoload() function, PHP only reports 'exception thrown in > __autoload' and no other information about the exception. Is > this a bug? I don't think so. The exception sh

Re: [PHP-DEV] Accessing child constants from base class

2003-10-11 Thread Marcus Börger
Hello Dan, Friday, October 10, 2003, 7:37:29 PM, you wrote: > Hi Marcus- > Marcus Börger wrote: >>Constants are bound to the class rather then to the objects. Hence they >>behave pretty much like static properties or default values of declared >>properties and like the latter they are read only

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Wez- Wez Furlong wrote: Performance wise, its not going to make much difference, because no matter what you are doing, to dynamically resolve the value of a constant will involve hash lookups. The other alternative, and this is the official POV of the Zend guys IIRC, is that you can use eval() to

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Wez Furlong
> >Performance wise, its not going to make much difference, > >because no matter what you are doing, to dynamically resolve > >the value of a constant will involve hash lookups. > > > >The other alternative, and this is the official POV of the > >Zend guys IIRC, is that you can use eval() to look

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Hi Wez- Wez Furlong wrote: This sounds like you're doing something wrong (no offense!). You want to access a *constant* of a descendant class, when your ancestor doesn't even know if it exists. Well, that sounds more than a little odd (backwards even). Why not just use a property with a know

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Hi Ard- Sorry, I must of misunderstood you. Yes, that would work fine. Now copy/paste the getElementName() function in the derived class to all 100's of other derived classes and wonder why you couldn't just do this with one base class function. :) Dan Cox Ard Biesheuvel wrote: This works fine

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Hi Marcus- Marcus Börger wrote: Constants are bound to the class rather then to the objects. Hence they behave pretty much like static properties or default values of declared properties and like the latter they are read only. understood. The only question here is whether we want to be able t

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Ard Biesheuvel
This works fine for me: abstract class Base { abstract function getElementName(); function getName() { return $this->getElementName(); } } class Derived extends Base { const ElementName = 'DerivedElementName'; function getElementN

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Ard Biesheuvel wrote: How about an abstract method in the base class called getElementName(), which each child will implement to return its element name. Hi Ard- This wouldn't work because the abstract method in the base class is still running in the 'base class scope' and can't see the child'

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Marcus Börger
Hello Dan, Friday, October 10, 2003, 10:53:20 AM, you wrote: > Marcus- > Marcus Börger wrote: >> Hello Dan, >> >> >>> 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 functi

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Marcus Börger
Hello Wez, Friday, October 10, 2003, 12:44:07 PM, you wrote: > This sounds like you're doing something wrong (no offense!). > You want to access a *constant* of a descendant class, when > your ancestor doesn't even know if it exists. > Well, that sounds more than a little odd (backwards even).

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Ard Biesheuvel
How about an abstract method in the base class called getElementName(), which each child will implement to return its element name. -- Ard -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Wez Furlong
t eval above. Hope that helps! --Wez. - Original Message - From: "Dan Cox" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 10, 2003 8:10 AM Subject: [PHP-DEV] Accessing child constants from base class > PHP5 10/10/2003 CVS. > > Currently, I don't

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
Marcus- Marcus Börger wrote: Hello Dan, 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();' Yes, this is possible,

Re: [PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Marcus Börger
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

[PHP-DEV] Accessing child constants from base class

2003-10-10 Thread Dan Cox
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. Consider the following basic example: abstract class myBaseClass { function getXML() { $doc = new domDocument(); $node = $doc->createElement(child::ElementName); $doc-