# CONSTANT names...

- Thread: https://externals.io/message/14281
- Original archive: https://news-web.php.net/php.internals/14281
- Started by Jochem Maas on 2005-01-04T23:57:57+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14282 — Johannes Schlueter — 2005-01-04T23:29:31+00:00

URL: https://externals.io/message/14281#14282 · In reply to: #14281

Hi Jochem,

you can get the valu of that constant with the `constant()` function and use
such a constant with `defined()` so forbidding this would at least be a BC
break.
btw. the same goes for reserved words so define('echo', 42); is valid too
but "echo echo;" doesn't work :-)

johannes
 
Jochem Maas wrote:

> hi guys,
> 
> I was mucking around and noticed the following:
> 
> define("404_SKIP", 1);
> 
> does not give an error and you can successfully get the value of the
> constant by doing:
> 
> constant("404_SKIP");
> 
> where as doing:
> 
> echo 404_SKIP;
> 
> gives an error.
> as I understand it, i.e. what the docs say, is that the following regexp
>   expresses valid starting chars for the name of a constant (the same
> going for vars):
> 
> /^[a-zA-Z_\x7f-\xff]/
> 
> so pretty minor thing here but I expected to see the `define()` throw a
> (fatal?) error, rather than letting me go on.
> 
> kind regards,
> Jochem

---

## #14281 — Jochem Maas — 2005-01-04T23:57:57+00:00

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

hi guys,

I was mucking around and noticed the following:

define("404_SKIP", 1);

does not give an error and you can successfully get the value of the 
constant by doing:

constant("404_SKIP");

where as doing:

echo 404_SKIP;

gives an error.
as I understand it, i.e. what the docs say, is that the following regexp 
  expresses valid starting chars for the name of a constant (the same 
going for vars):

/^[a-zA-Z_\x7f-\xff]/

so pretty minor thing here but I expected to see the `define()` throw a 
(fatal?) error, rather than letting me go on.

kind regards,
Jochem

---

## #14283 — Andi Gutmans — 2005-01-05T01:24:06+00:00

URL: https://externals.io/message/14281#14283 · In reply to: #14281

There are plenty of such examples in many languages. As Johannes mentions, 
some ppl might even be "abusing" it already :)
Anyway, I don't think adding necessary checks for such things, and slowing 
 `define()` down (even if it's negligible) is warranted in such cases.

Andi

At 12:29 AM 1/5/2005 +0100, Johannes Schlueter wrote:
>Hi Jochem,
>
>you can get the valu of that constant with the `constant()` function and use
>such a constant with `defined()` so forbidding this would at least be a BC
>break.
>btw. the same goes for reserved words so define('echo', 42); is valid too
>but "echo echo;" doesn't work :-)
>
>johannes
>
>Jochem Maas wrote:
>
> > […]
