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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: al at humantouch dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 15:01:29 2024 UTC