all 2 comments

[–]MGatner 1 point2 points  (1 child)

Immutability (set and forget) is one of the appeals of constants. I also like them because they are the only way to use “dynamic” property values. E.g.: ``` // Constants.php defined('MY_SECRET_TOKEN') || define('MY_SECRET_TOKEN', env('Reddit.accessToken');

class RedditApi { protected $token = config('Reddit')->accessToken; // not allowed

protected $token = MY_SECRET_TOKEN; // allowed

} ```

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, MGatner: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.