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

Answer Posted / abhishek baranwal

define("CONSTANT", "Hello world.");

echo CONSTANT; // Outputs Hello world


define("CONSTANT", "New Value");

echo CONSTANT; // Outputs Hello world

Means once you declair the define a constant value that
will become every time it will not take new value or it
will not redeclair.if you want change in value then declair
the variables for that purpose.

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to check curl is enabled or not in PHP

636


What are the ways to define a constant in php?

526


What are the methods to submit form in php?

529


What is php explain?

513


Where is php code written?

517






What are helpers in php?

474


How to write a program to make chess?

547


How to replace a substring in a given string in php?

551


What is a controller in php?

556


Tell me how can we check the value of a given variable is alphanumeric?

497


How to get the value of current session id?

536


What is inheritance in php with example?

553


Which database is best for php?

534


Are php variables global?

560


How long is session timeout?

530