php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #1333 calls to parent methods would be handy
Submitted: 1999-04-20 10:51 UTC Modified: 1999-04-20 15:40 UTC
From: maarnold at gte dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.5 OS: linux
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: maarnold at gte dot net
New email:
PHP Version: OS:

 

 [1999-04-20 10:51 UTC] maarnold at gte dot net
It would be nice if a derived class could, within an overridden method, call the method of the same name in the parent class. For example ...

class DbTblC
	{
	var $id;
	var $othervar;

	function DbTblC()
		{
		$this->RReset();
		} // function DbTblC()

	function RReset()
		{
		$this->id=0;
		$othervar = "";
		} function RReset()
	} // class DbTblC

class AuthTblC extends DbTblC
	{
	function RReset()
		{
		$parent->RReset();
		$this->id = md5(uniqueid(random()));
		} // function RReset()
	} // class AuthTblC

What I have done as a work around is rename the RReset() function to RResetFields() and then stubbed the RReset() function to do nothing more than call RResetFields()...
class DbTblC
	{
...
	RResetFields()
		{
		$this->id=0;
		Rthis->othervar="";
		}

	RReset()
		{
		$this->ResetFields();
		}
	}

 Then the derived class can override RReset() with...
	function RReset()
		{
		$this->RResetFields();
		$this->id=md5(uniqueid(random)));
		}

This might work, but it rather loses some of the poetry of object oriented programming.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-04-20 15:40 UTC] andi
Although we don't want to make PHP a true OO language we've decided to add this capability in PHP 4 (the Zend engine)
as it makes a lot of sense and is pretty useful.
However, it won't be supported in PHP 3.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 20:00:01 2026 UTC