ProAnswers.org

How do you define a constant in PHP?

How do you define a constant in PHP?

You can define a constant using the define() directive.

 

you can use this a number of ways;

 

to define a variable to a constant do:

 

$string = "hello";

define("string",$string);

 

to define a string to a constant use:

 

define("hello","there");

 

to define a integer or other numerical value use:

 

define("number",1.0);

 

Summery:

 

to define a string use quotes as you would do a string.