+ 2

what is the specific use of constant?

if you could give me an example when to use it when there is a function that would change values.

15th Sep 2016, 9:00 AM
jklasd09
jklasd09 - avatar
11 Réponses
+ 11
you can use it to declare databse arguments and it helps to protect them from changing. for example: <?php define("DB_NAME","dbname"); define("DB_USER","dbuser"); define("DB_PASSWORD","dbpassword"); define("DB_HOST","dbhost"); ?> so if a hacker attempts to change db info it will not change
16th Sep 2016, 2:18 AM
Ilyosjon Kamoldinov
Ilyosjon Kamoldinov - avatar
+ 2
Just declare constant the stuff you don't wanna change.
15th Sep 2016, 9:26 AM
Zen
Zen - avatar
+ 2
@bm i'm trying to get infos here. @ahmed sorry i misunderstand what you said. i thought u said pls dont mind my question.
17th Sep 2016, 12:52 PM
jklasd09
jklasd09 - avatar
+ 1
please demonstrate in coding when any body asks for an example. here the example of a constant must be coding
15th Sep 2016, 3:39 PM
Ahmed Kamal
Ahmed Kamal - avatar
+ 1
tysm Ilyosvek!
16th Sep 2016, 2:55 AM
jklasd09
jklasd09 - avatar
+ 1
please don't mind brother jaz. I was just presenting a suggestion because I m also a learner
17th Sep 2016, 10:39 AM
Ahmed Kamal
Ahmed Kamal - avatar
+ 1
for more details ..u can visit 'w3school' in php section
17th Sep 2016, 10:42 AM
B.M. ASHIK MAHMUD
B.M. ASHIK MAHMUD - avatar
+ 1
Use the constant when you define something, that never change in your project. Example: PI number is alway = 3.14. So you use: defint("PI", 3.14);
31st Oct 2016, 10:00 AM
Việt Dũng Đặng Quang
Việt Dũng Đặng Quang - avatar
0
@viet if we try 2 change the constant value,is it change or it will display exception or new memory allocate for that variable and its value being changed
6th Aug 2017, 1:29 PM
Anand Kumar
Anand Kumar - avatar
- 1
when u work on DBMS ..u will know by yourself;)
17th Sep 2016, 10:35 AM
B.M. ASHIK MAHMUD
B.M. ASHIK MAHMUD - avatar
- 2
please don't mind
15th Sep 2016, 3:39 PM
Ahmed Kamal
Ahmed Kamal - avatar