+ 1
In PHP, Why do I need to define case sensitive in a constant?
it is a constant it wont change. I dont understand the concept or the use of it. Somebody can help me?
7 Answers
+ 3
Variables are "flexible" values that can be changed, for example sum = 5+4 (sum equals 9), sum += 10 (sum equals 19) etc.
Constants are values that can't be changed, for example PI = 3.1416 (Ï is always a fixed value and doesn't need to be changed).
In most languages, it is good practice to begin names of constants with a capital letter (Pi) or to capitalize the whole name (PI). In some languages (I think for example in Ruby), it is automatically assumed that an object whose name starts with a capital letter is a constant and its value can't be changed after its initialization.
+ 1
Thanks for Your answear but the question remains, why do I have to specify true or false for case sensitive
+ 1
Jorge Cueva Uh, let's start with the question what programming language you're talking about. Do you have an example of where you're asked to specify true or false?
+ 1
PHP
+ 1
<?php
define("MSG", " Hi SoloLearners!", true);
echo msg;
// Outputs "Hi SoloLearners!"
?>
by default comes with case-insensitive
+ 1
this us the function define(name, value, case-insensitive)
+ 1
I already understood, by default it is "false" so it is - and - = + means that it will be case sensitive. So if you put the name of your constant all in capital letters for example, and send to call the constant in lowercase letters does not work