PHP Constants MCQs

PHP Constants MCQs : This section focuses on "Constants" in PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. A ___________ is a name or an identifier for a simple value.

A. variable
B. data type
C. constant
D. array

View Answer


2. Can we change the value of constant during the execution of the script.

A. can
B. can not
C. depends on data type
D. depends on variable

View Answer


3. By default, a constant is _________.

A. case-sensitive
B. case-insensitive.
C. Both A and B
D. None of the above

View Answer


4. To define a constant you have to use ________ function.

A. const()
B. constant()
C. def()
D. define()

View Answer


5. _________ function is used to read a constant value.

A. read()
B. get()
C. constant()
D. define()

View Answer


6. There is no need to write a dollar sign ($) before a constant

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


7. Which of the following is true about constant?

A. Once the Constants have been set, may not be redefined or undefined
B. Constants may be defined and accessed anywhere without regard to variable scoping rules
C. Constants cannot be defined by simple assignment, they may only be defined using the define() function
D. All of the above

View Answer


8. How many magical constants there?

A. 4
B. 5
C. 6
D. 7

View Answer


9. What will be the output of the following PHP code?

class myObject { }
define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;

A. test
B. error
C. myObject::CONSTANT
D. no output

View Answer


10. What will be the output of the following PHP code?

define('IF', 42); 
echo ""IF: "", IF;

A. IF:42
B. No output
C. IF:
D. Error

View Answer




Discussion



* You must be logged in to add comment.