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
{
    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.

Reply via email to