note 80480 rejected from function.get-parent-class by nlopess

From: Date: Fri, 18 Jan 2008 12:49:39 +0000
Subject: note 80480 rejected from function.get-parent-class by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135189@lists.php.net to get a copy of this message
Note Submitter: biaggi at gmail dot com ---- I have a problem a class. if we have two classes: <?php class a { function a () { if (get_class($this) == 'b') { return NULL; } else { return parent::a(); } } } class b extends a { } $bObj = new b(); $bObj->a(); ?> The problem is that I get an error: PHP Fatal error: No parent class available in [file] on line [line] I've solved the problem writing new class, so the code would read: <?php class a { function a () { return NULL; } } class c extends a{ function a () { if (get_class($this) == 'b') { return NULL; } else { return parent::a(); } } } class b extends c { } $bObj = new b(); $bObj->a(); ?> There is another solution on this problem?

« previous php.notes (#135189) next »