How do I define a constant in PHP?
And here is how:
<?php
define('NAME', 'Tarquin');
?>
This defines a constant called NAME and assigns it the value of Tarquin. Now assuming you don't ever change your name (well, maybe if you're called Tarquin...) then this would be a possible instance of defining a constant.
How do you access it? Like this:
<?php
echo 'Hello, ' . NAME;
?>
It is very important to note that the constant is printed outside of any quotation marks; include it within them and you will just see NAME printed to screen rather than the actual value of the constant.
Comment on this Question and Answer >>>
ASK A QUESTION
More other PHP Questions
What is the difference between the while and do while loops?Can I spellcheck my text using PHP?
how can i put the value 1 or 0 into checkbox if we checked then 1 otherwise 0?
Can PHP create PDF files for me?
How do I check if a date entered exists?
