RE: [PHP-DEV] PHP 4.0 Bug #8565 Updated: parent:: only works when both classes in the same file.
| From: | Chris Newbill | Date: | Fri, 05 Jan 2001 19:37:35 +0000 |
| Subject: | RE: [PHP-DEV] PHP 4.0 Bug #8565 Updated: parent:: only works when both classes in the same file. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-43076@lists.php.net to get a copy of this message | ||
Same results on 4.0.4 CGI.
>><br>
>><b>Fatal error</b>: No parent class available in this context in
>><b>/www/subsupp/del/a.inc</b> on line <b>6</b><br>
If you change extend-test.php to have _both_ includes, it works just fine.
>>Class Base->doit()
>>Class A->doit()
Chris
> -----Original Message-----
> From: jalal@php.net [mailto:jalal@php.net]
> Sent: Friday, January 05, 2001 12:32 PM
> To: hholzgra@php.net
> Cc: PHP DEV
> Subject: Re: [PHP-DEV] PHP 4.0 Bug #8565 Updated: parent:: only works
> when both classes in the same file.
>
>
>
> Yes, I've used it in the past...
>
> The following code gives the error:
>
> file: base.inc
> <?php
>
> class Base {
> function Base(){}
> function doit() {
> echo "Class Base->doit()\n";
> }
> }
> ?>
>
> file: a.inc
> <?php
> include("base.inc");
> class A extends Base {
> function A(){}
> function doit() {
> parent::doit();
> echo "Class A->doit()\n";
> }
> }
> ?>
>
> file: extend-test.php
> <?php
> include("a.inc");
>
> $a = new A();
>
> $a->doit();
>
> ?>
>
> x:>php -f extend-test.php
> Fatal error: No parent class available in this context in a.inc on line 6
>
> HTH, jalal
>
> On 5 Jan 2001 hholzgra@php.net wrote:
>
> > ID: 8565
> > Updated by: hholzgra
> > Reported By: jalal@php.net
> > Old-Status: Open
> > Status: Feedback
> > Bug Type: Scripting Engine problem
> > Assigned To:
> > Comments:
> >
> > sorry, but i can't believe this as i
> > use this feature almost daily
> >
> > can you pleas provide an example of
> > code _not_ working ?
> >
> > Previous Comments:
> >
> ------------------------------------------------------------------
> ---------
> >
> > [2001-01-05 12:22:36] jalal@php.net
> > the parent:: operator will work if both the parent and sub
> class are in the same physical file, but not if they are in a
> separate file.
> >
> > This works:
> >
> > <?php
> > class Base {
> > function doit() {
> > echo "Class Base->doit()n";
> > }
> > }
> > class A extends Base {
> > function doit() {
> > parent::doit();
> > echo "Class A->doit()n";
> > }
> > }
> > ?>
> >
> > but if the two classes are in separate files, the following
> error is reported:
> > Fatal error: No parent class available in this context in
> a.inc on line 6
> >
> > Of course, this may be an undocumented feature, but I can see
> no reason for it.
> >
> >
> ------------------------------------------------------------------
> ---------
> >
> >
> > Full Bug description available at: ü"b
> > ì̤WüòˆÍ¼http://bugs.php.net/?id=8565
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-dev-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>