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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC