Re: define and objects!
| From: | David Coallier | Date: | Sun, 29 Apr 2007 23:30:34 +0000 |
| Subject: | Re: define and objects! | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-29106@lists.php.net to get a copy of this message | ||
On 4/29/07, MaaSTaaR <el7zndotcom@yahoo.com> wrote:
Hello ... Firstly sorry for my bad English, my friend request from me to send this suggestion for PHP developer. The suggestion is support use constant as object, for example : class HelloWorld {You could just do class Main { public static function P() {function start() { echo 'Hello World'; }} define('OBJ',new HelloWorld); OBJ->start(); this will be good when we use object inside class, we will not need use global or $this, for example. With normal way : class MainClass {function One() { echo 'One'; }function Two() { echo 'Two'; }} $Main = new MainClass; class AnotherClass {function P() { global $Main; // Note this line$Main->One(); }} With suggested way : class MainClass {function One() { echo 'One'; }function Two() { echo 'Two'; }} define('MAIN',new MainClass); class AnotherClass {function P() { MAIN->One(); // use it directlly without global or $this }} --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos.
echo 'woo';} } class Yeah { public function S() {
Main::P();} } -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18