In the file function. Isn't it simple to write w and w + directly? why do we need to go around? Some frameworks even define the 60 minute-minute 60 seconds as constants, and there is a long constant name. Why do constants need to be used for such things that will never change? In addition, I think it is written as $ t360. .. and then called in the file function. Isn't it simple to write w and w + directly? why do we need to go around?
Some frameworks even define the 60 minute-minute 60 seconds as constants, and there is a long constant name. Why do constants need to be used for such things that will never change? In addition, I think the format $ t = 3600*24 is not quite readable.
Reply content:
In the file function. Isn't it simple to write w and w + directly? why do we need to go around?
Some frameworks even define the 60 minute-minute 60 seconds as constants, and there is a long constant name. Why do constants need to be used for such things that will never change? In addition, I think the format $ t = 3600*24 is not quite readable.
Thank you!
The full name of a variable is used to increase readability. for example, single-letter functions have been criticized for The Times before thinkphp5, but they are not readable and can't be understood as soon as they are seen.
Constants are generally defined in one file or in the same location for easy maintenance.
It can be called repeatedly in multiple places. Once modified, you only need to change one place.
This value must have been called many times by the entire project. if it is not set as a constant, it is likely to be missed if you want to modify this value.
1 The current time is defined as a constant to reduce the time error, which is generally defined at the entry. Because the business logic exists, the request time is not the same as the data warehouse receiving time. For example, when a user clicks to submit an answer, your business logic is to execute 0.1 billion cycles and then write them into the database. The operation time recorded by your database is different from the actual user's operation time.
2. prevent time difference caused by multiple use of time ()
3. there is a lot of pressure on storage, and there is a cloud. there is a first framework written like this. before the new framework is developed, it will certainly be referenced by others.
Like a judgment statement
if($a>1){$a=1;}
Some people write it like this.
if($a>1) $a=1;
Some people write it like this.
$a>1 and $a=1;
There is something like this:
$a>1 && $a=1;
As long as you can understand it, you can use one of your habits.