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

What is binary safe function in php?

566


Tell me what is the definition of a session?

548


What is the difference between apache and tomcat?

524


What is the difference between explode() and split() functions?

496


Is php dying 2018?

541






What types of MYSQL function available for affecting columns

546


Is wordpress a php framework?

517


What is orm in php framework?

487


How to Retrieve the Session ID of the Current Session?

526


Is php a dying language?

532


What are escaping characters? Explain with an example?

511


Tell me which programming language does php resemble to?

497


What are the php functions?

542


Is php an array?

510


What is mysql_fetch_object?

553