note 20582 deleted from keyword.parent by vincent

From: Date: Thu, 09 Oct 2003 17:44:05 +0000
Subject: note 20582 deleted from keyword.parent by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58154@lists.php.net to get a copy of this message
Note Submitter: php@earthside.arg ---- Trying the technique shown above for chaining constructors. Below is a minimal example. Additional tests (move 'echo $cls' above the '$this->$par()' call) show recursive calls to bar(), since get_parent_class($this) always seems to resolve to baz.... #cat test.php <?php class foo { function foo() { $cls = get_class($this); echo $cls."\n"; } } class bar extends foo { function bar() { $cls = get_class($this); $par = get_parent_class($this); $this->$par(); echo $cls."\n"; } } class baz extends bar { function baz() { $cls = get_class($this); $par = get_parent_class($this); $this->$par(); echo $cls."\n"; } } $o = new baz; ?> #php test.php Segmentation fault (core dumped) # It seemed like a good idea, but ... help? -- change the 'a' to 'o' in the TLD to email

« previous php.notes (#58154) next »