Jump to content

use of define and classes


Renlok

Recommended Posts

Yes it is.

 

define('THIS', 1);

class that
{
    function that() {
        echo "THIS was : " . THIS;
    }
}

$that = new that();

 

Should echo out THIS was 1 once the class is instantiated. If THIS is not defined it would echo out THIS with a notice of an undefined constant.

 

That is the point of a constant, it can be used anywhere within a script as long as it is defined before you try to use it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.