how to access the super class from a child class in php -


i have 3 classes following inheritance structure:

   <?php      class admin {        function __construct($module){          echo $module;        }      }       class user_admin extends admin {        function __construct(){          parent::__construct('user');        }      }       class sales_admin extends user_admin {        function __construct(){          parent::__construct('sales');        }      } 

you'll notice sales_admin extends user_admin, nescessary step. when run code,

$a = new sales_admin; 

it echo "user", because passes "sales" string user_admin doesn't accept constructor.

is there way access constructor of parent above without changing user_admin, don't have control over?

just reference class directly:

class sales_admin extends user_admin {     function __construct()     {         admin::__construct('sales');     } }  $a = new sales_admin; // outputs 'sales' 

since user_admin extends admin, , sales_admin extends user_admin, sales_admin have scope of admin constructor


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -