RE: [PEAR-DEV] PEAR OO style: associative array parameter vs. une ncapsulated cla ss

From: Date: Mon, 12 May 2003 17:12:27 +0000
Subject: RE: [PEAR-DEV] PEAR OO style: associative array parameter vs. une ncapsulated cla ss
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16192@lists.php.net to get a copy of this message
Jesus wrote: > As for __get()/__set(), they are there as convinience methods (if I understand correctly), > so if a particular var does not really exist but is generated from (for example) a database query > and some math, it will be done that transparently to the user. This is maybe a bit off-topic but on the subject of __get()/__set()... it seems to me that another use-case for them in addition to the above is to facilitate mixing PHP and HTML. Leaving aside the debate on custom template languages vs. vanilla PHP+HTML, in situations where you are mixing PHP and HTML it's rather inconvenient that you can't express a function call inside a double-quote or heredoc string literal. E.g. {$this->foo} is fine but not {$this->foo()}. I find this leads to a lot of otherwise-unnecessary local variables and/or ugly back-and-forth between HTML parsing mode and PHP parsing mode (with "<?php echo $this->foo(); ?>" scattered throughout HTML blocks), so it would seem to me that using overloading (so the previous is just {$this["foo"]} in a heredoc block) could in some situations provide some of the simplification power of PHP template packages as built-in functionality to PHP. I guess I mention this partly since I don't see any mention in the PEAR coding standards around how to handle presentational code style, of course most PEAR components are 100% UI-free middleware libraries but not always. --Bill

« previous php.pear.dev (#16192) next »