0
Constants value
Why I should write age only 28 in this case?: <?php define(“AGE”, 28); ?> Because if I write 25 for example it is a wrong answer.
9 odpowiedzi
+ 1
no, i don’t. Because in other examples age = 25 or other. Why only 28?
+ 6
It is considered wrong answer because the lesson quiz specifically tells to create a constant named "AGE" with value 28. Having been instructed just that, of course assigning a constant value other than 28 would be wrong : )
https://www.sololearn.com/learn/PHP/2331/
+ 6
AgentSmith, my pleasure, and good job! 👍
+ 4
define(“AGE”, 28);
^That's the constant you defined, so it'll always be 28. However, you can change the 28 to whatever number you want in the definition for it, but the rest of the code won't be able to change it since it is a constant. Get what I mean? Typically, AGE should be dynamic and not a constant since the age of anything changes over time. A good example of a constant could be the number of days in the week, days in the year, seconds in a minute, minutes in an hour, year something was created, etc... - anything that typically doesn't change and you wouldn't want to change.
+ 3
age = 25
^That's a variable (in math, variables have changing values)
define(“AGE”, 28);
^That's a constant (they have values that do not change)
However, when you're programming, you're the one that determines which are constants and which are variables, so it isn't bound to only being 28 unless you create a constant and set it to a value of 28 in its definition that you write. In the code you posted, you set it to a value of 28, which is why the constant will have a value of 28.
+ 3
@Ipang
Thanks. This entire thread makes a lot more sense now that I know it's being based on a quiz. :D
+ 1
okay, thanx a lot for your comment)
0
Me ayudan en C#