Re: [Strawpoll] Promoting redefining constant to exception
| From: | Bruce Weirdan | Date: | Tue, 25 Jan 2022 20:25:22 +0000 |
| Subject: | Re: [Strawpoll] Promoting redefining constant to exception | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116923@lists.php.net to get a copy of this message | ||
On Tue, Jan 25, 2022 at 9:45 PM Chase Peeler <chasepeeler@gmail.com> wrote:
> it will make this much more difficult to read since the constants.php will have to be
> updated:
>
> if(!defined('dbserver')){
> define('dbserver','productiondb.example.com');
> }
> if(!defined('otherconstant')){
> define('otherconstants','foobar');
> }
You could use this form for conciseness:
```
defined('dbserver') or define('dbserver',
'productiondb.example.com');
defined('otherconstant') or define('otherconstant', 'foobar');
```
IMHO it's clearer than
@define() as it makes it explicit where you
expect a possible previous definition and where you don't.