Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Inheretance VS passing classes

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Inheretance VS passing classes

Postby iconofsin » Thu Jun 05, 2014 2:37 pm

Is there any functional difference between the two following pieces of code other than the fact that with extended/inherited classes the properties of the parent class would be lost if they matched a property of the child class.

------------------

class foo
{
public $A;
}

class bar extends foo
{
}

$C = new bar();
$C->A;

-------------------------

class foo
{
public $A;
}

class bar
{
public $B;
}

$C = new bar();
$C->B = new foo();
$C->B->A;
iconofsin
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 05, 2014 2:30 pm

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.