php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11850 anormal behavior of keyword parent
Submitted: 2001-07-02 21:39 UTC Modified: 2001-07-15 12:57 UTC
From: gerardo at lania dot mx Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: SunOS 5.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gerardo at lania dot mx
New email:
PHP Version: OS:

 

 [2001-07-02 21:39 UTC] gerardo at lania dot mx
the use of the parent keyword when the inherited class is in a different file from the parent class produces an error:
(just by  writing both classes on a single file avoids the problem)

Fatal error: No parent class available in this context in file_of_inherited_class.php

example:

file: a.php
--------------
class a {
	function f() {
		echo "a::f()" ;
	}	
}

file: b.php
---------------
class b extends a {
	function f() {
		echo parent::f() ;	// <---- error when compiling 
		echo "b::f()" ;
	}	
}

$obj = new b() ;
$obj->f();

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-15 12:57 UTC] zeev@php.net
This has been fixed in the CVS, and will be a part of PHP 4.0.7
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 11:01:29 2025 UTC