Differentiate between variables and constants in PHP
0
A few differences between variables and constants in PHP are given below:
| Constants | Variables |
| There is no need to write a dollar ($) sign before a constant | A variable must be written with the dollar ($) sign |
| Constants can only be defined using the define() function | Variables can be defined by simple assignment |
| Constants may be defined and accessed anywhere without regard to variable scoping rules. | In PHP, functions by default can only create and access variables within their own scope. |
| Constants cannot be redefined or undefined. | Variables can be redefined for each path individually. |
Sign in to add a comment
0 Answers
0
📝 No answers yet!
Be the first to answer this interview question.
Your Answer
Sign in to post your answer and help the community.