note 33724 modified in keyword.parent by felipe

From: Date: Sat, 19 Jul 2008 20:31:46 +0000
Subject: note 33724 modified in keyword.parent by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141722@lists.php.net to get a copy of this message
There is a difference between PHP and C# managing the overloaded variables of the parent class: <?php class a{ var $a=1; function display(){ echo $this->a; } } class b extends a{ var $a=9; } $x=new b; $x->display(); // will display 9 ?> The same code in C# will display the value from the parent class. [C#] class a{ private int a=1; public int display(){ return this.a; } } class b:a{ private int a=9; } b x = new b(); Response.Write(b.display()); // will display 1 --was-- There is a difference between PHP and C# managing the overloaded variables of the parent class: [PHP] class a{ var $a=1; function display(){ echo $this->a; } } class b extends a{ var $a=9; } $x=new b; $x->display(); // will display 9 The same code in C# will display the value from the parent class. [C#] class a{ private int a=1; public int display(){ return this.a; } } class b:a{ private int a=9; } b x = new b(); Response.Write(b.display()); // will display 1 http://php.net/manual/en/keyword.parent.php

« previous php.notes (#141722) next »