Re: php5 oop question
| From: | Jim Lucas | Date: | Thu, 12 Apr 2007 06:36:56 +0000 |
| Subject: | Re: php5 oop question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252706@lists.php.net to get a copy of this message | ||
Paul Scott wrote:
On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:Here is the other example that I worked up. <plaintext><?php class Math { function __construct() { } function in($num=null) { if ( is_null($num) ) { echo "A number was not given on initialization."; exit; } $this->value = $num; return $this; } function out() { echo $this->value; } function get() { return $this->value; } function add($n) { $this->value += $n; return $this; } function subtract($n) { $this->value -= $n; return $this; } function multiply($n) { $this->value *= $n; return $this; } function divide($n) { $this->value /= $n; return $this; } } $mObj = new Math(); $mObj->in(10)->add(90)->divide(5.3)->multiply(10)->out(); ?>Has anybody else seen this style of syntax?http://5ive.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=init_8059_1163957717&userid=5729061010 I don't think that its really useful for anything, except maybe creating overly complex SQL queries. --Paul ------------------------------------------------------------------------ All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm What about using it for math?