isolated php issue in embedded constructors -


i have php:

public function __construct($config) {     if (!session_id()) {       session_start();     }     parent::__construct(array $config) { // line no 52        if (!empty($config['sharedsession'])) {         $this->initsharedsession();       }    }  }  

i eror says line 52 should t_variable. i've given up. do.

there's no such thing "embedded constructors" in php. code show invalid nonsense, plain , simple. i'm not sure other language come or expectations have in php, doesn't whatever you're trying there.

to clarify how overriding methods works, because seems you're trying do:

class foo {      public function __construct($value) {         echo $value;     }  }   class bar extends foo {      public function __construct($value) {         echo $value . ' bar';     }  }   class baz extends foo {      public function __construct($value) {         echo $value . ' baz';         parent::__construct($value);     }  }  new foo(42);  // 42 new bar(42);  // 42bar new baz(42);  // 42baz42 

to override method in child class, implement method of same name in child. parent's method of same name thereby overridden , not executed anymore. can call parent's implementation of method using parent::methodname(). nothing more, nothing less.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -