How to Define a Constant in PHP? Is $ symbol necessary?

Answer Posted / nilsoft

define("CONSTANT", "Its constant");

echo CONSTANT; // Outputs Its Constant

There is no need to use $ sign for it.
$ sign is used for declare variables.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between required and require_once in php?

549


Explain how we can retrieve the data in the result set of mysql using php?

507


Do you know what are traits?

536


Explain me what are the 3 scope levels available in php and how would you define them?

736


What is mvc in php?

537






How should a model be structured in mvc?

529


What software is required for php?

542


Explain the difference b/w static and dynamic websites?

500


What are different types of Print Functions available in PHP?

532


What is difference between get and post in php?

614


What are php errors?

499


How can we check the value of a given variable is alphanumeric?

546


What is form submission?

551


How variables are passed through arguments?

558


What are php expressions?

609