Re: How can I do this -- method chaining
| From: | Richard Heyes | Date: | Tue, 29 Jan 2008 19:02:27 +0000 |
| Subject: | Re: How can I do this -- method chaining | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-268267@lists.php.net to get a copy of this message | ||
Christoph Boget wrote:
Constructors return the object, correct? If so, how can I do this: class Bob { private $blah; _construct( $blah ) {Bob is a class, not a method. You could try this: <?php$this->blah = $blah;} public getBlah() {return $this->blah;} } echo Bob( 'Hello!' )->getBlah(); When I try that, I get the message "Undefined function Bob". I've also tried echo new Bob( 'Hello!' )->getBlah(); echo (new Bob( 'Hello!' ))->getBlah();
$obj = new Bob();
$obj->getBlah();
?>
It's not method chaining though.
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and Helpdesk software for £299pa hosted for you -
no installation, no maintenance, new features automatic and free