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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 + 40 = ?
Subscribe to this entry?

 
 [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: Tue May 07 07:01:32 2024 UTC