Sr. PHP Programmer Question:
Download Job Interview Questions and Answers PDF
What is the purpose of constant() function?
Answer:
As indicated by the name, this function will return the value of the constant. This is useful when you want to retrieve value of a constant, but you do not know its name, i.e. It is stored in a variable or returned by a function.
<?php
define("GlobalGuideline", 50);
echo GlobalGuideline;
echo constant("GlobalGuideline"); // same thing as the previous line
?>
Only scalar data (boolean, integer, float and string) can be contained in constants.
<?php
define("GlobalGuideline", 50);
echo GlobalGuideline;
echo constant("GlobalGuideline"); // same thing as the previous line
?>
Only scalar data (boolean, integer, float and string) can be contained in constants.
Download Senior PHP Programmer Interview Questions And Answers
PDF
Previous Question | Next Question |
What are getters and setters and why are they important? | How will you send an email using PHP? |