inheritance - How to overwrite variables from a parent class in PHP? -


i struggling problem 1 has following setup:

class model {     public $tableconnection = null;      .... } 

now there class inherits model.

class newmodel extends model {     public $tableconnection = array("belongsto" => "othermodel");      ... } 

what acchieve define tableconnection putting definition child class (newmodel) in order overwrite original variable within class model.

newmodel should simple possible without additional methods or functions, instead model can include useful. maybe recognized similarity cakephp framework. trying understand how things can acchieved. , maybe there php wizzard out there knows how deal :-)

it working, please check here:-

<?php  class model {     public $tableconnection = null; } class newmodel extends model {     public $tableconnection = array("belongsto" => "othermodel"); } $obj = new newmodel(); print_r($obj->tableconnection); ?> 

output:-https://eval.in/509293


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -