php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12850 May a feature to add?
Submitted: 2001-08-20 01:34 UTC Modified: 2001-08-20 03:38 UTC
From: al at humantouch dot de Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.4pl1 OS: Red Hat
Private report: No CVE-ID: None
 [2001-08-20 01:34 UTC] al at humantouch dot de
Hi,

here is a tricky thing using the parent:: keyword:
There seems to be no way to call a parent function out of a 
parent function!

<?php

class test {

	function test1(){
		echo "parent:test1<br>";
		}
		
	function test2(){
		echo "parent:test2<br>";
		$this->test1();
		}
	
	
	}
	
class sub extends test {

	function test1(){
		echo "sub:test1<br>";
		}
		
	function test2(){
		echo "sub:test2<br>";
		parent::test2();
		}
		
	}
	
	
$a = new sub();
$a->test2();
?>

returns:

sub:test2
parent:test2
sub:test1

Greetings,


Alex

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-20 03:38 UTC] ssb@php.net
If you need to call specific class methods, use test::test1() instead of $this->test1().  The $this variable will still be defined.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC