+ 1

constant

Are you can teach me what is a constant simply ? because i not understand

23rd Jul 2016, 9:47 AM
Habib
6 ответов
+ 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.
24th Jul 2016, 1:21 AM
GlennV
0
hmmm
23rd Jul 2016, 1:01 PM
Stephen Ok Ogu
Stephen Ok Ogu - avatar
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.
6th Aug 2016, 9:37 AM
shankar J
shankar J - avatar
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.
8th Sep 2016, 4:05 PM
Bhuvaneswari R
Bhuvaneswari R - avatar
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
29th Sep 2016, 11:34 AM
Daniel Oseka
Daniel Oseka - avatar
- 1
constant can similar of variable except of they ,can not change value
25th Jul 2016, 9:28 AM
Laxmi Bharti
Laxmi Bharti - avatar