# string operators for assigning class constants

- Thread: https://externals.io/message/35667
- Original archive: https://news-web.php.net/php.internals/35667
- Started by Sebastian on 2008-02-20T22:08:58+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #35667 — Sebastian — 2008-02-20T22:08:58+00:00

URL: https://externals.io/message/35667#35667

hi,

why isn't it possible to assign class constants like this:

class test
{
           const 
DIR='dirname'.DIRECTORY_SEPARATOR.'anotherdirname'.DIRECTORY_SEPARATOR;
}

is there some performance issue?
anyone ever tried this or was there a discussion about it? i would find this 
very useful.....

greetings

---

## #35685 — Antony Dovgal — 2008-02-21T12:06:59+00:00

URL: https://externals.io/message/35667#35685 · In reply to: #35667

> hi,
> 
> why isn't it possible to assign class constants like this:
> 
> class test
> {
>            const 
> DIR='dirname'.DIRECTORY_SEPARATOR.'anotherdirname'.DIRECTORY_SEPARATOR;
> }

Because concatenating is an expression, expressions are executed in runtime (2nd stage) 
and classes are declared in compile-time (1st stage).

-- 
Wbr, 
Antony Dovgal
