+ 1
constant
Are you can teach me what is a constant simply ? because i not understand
6 Antworten
+ 5
Define("MyConstant", 21);
Echo MyConstant; //notice no variable $ symbol
A constant is like a variable however its value cant be changed when set.
Also constants are global and can be reached anywhere (ex: functions)
A third possible parameter of define (default=false) can be set to true if you want the constant to be case insensitive.
0
hmmm
0
constant is nothing like a variable except whose value is fixed. i will tell you one practical usage. say you are coding a project, which contains 5000 lines of code. in that code you are using same hardcoded string which repeats 100 times (say an ip address) in various parts. in this situation you could use this constant feature. so in future if your ip address changes you can update it in only one place not through the entire code.
0
we can use the value 100 is used as many times in our programe that can declared as variable a=100 and then use the variable a as your code this are constant.
0
1 constant cannot be changed
2.it declaration style is diff from that of variable.
3 the dollar sign it's not needed during echo i. e echo constant name
- 1
constant can similar of variable except of they ,can not change value