constant values example in oop


/*constant values are important when you want to make value remain unchanged all over the script..
Constant properties can contain only primitive values. You cannot assign an object to a constant.
Like global constants, class constants
cannot be changed once they are set. A constant property is declared with the const keyword. Constants are not prefixed with a dollar sign like regular properties.

constant values are prefixed with const keyword ..


class ap
const FLAG = 0;

public function change()
$this->FLAG = 2;
public function show()
echo $this->FLAG;

$object = new ap();



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s