# constant name

- Thread: https://externals.io/message/9674
- Original archive: https://news-web.php.net/php.internals/9674
- Started by Jason Garber on 2004-05-05T20:43:11+00:00
- Messages: 2
- 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

---

## #9674 — Jason Garber — 2004-05-05T20:43:11+00:00

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

Does it output "barfoo" or "bar"?
~Jason


At 5/5/2004 10:01 PM +0200, Mehdi Achour wrote:
Hi !

The manual reads :

"The name of a constant follows the same rules as any label in PHP. A
valid constant name starts with a letter or underscore, followed
by any number of letters, numbers, or underscores. As a regular
expression, it would be expressed thusly:
'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]'"


I know that this is true when trying to echo a constant directly, as the 
parser raise an error, but you can trick it with a `constant()` call :

<?php

define('
(\ /)
{=B0_=B0)
() ()
( )( )
', 'barfoo');

echo constant('
(\ /)
{=B0_=B0)
() ()
( )( )
') . chr(10); // outputs : bar

Is it a feature or a bug ? :)

Mehdi Achour

-- 



__________________________________________________________
Jason Garber
President & Chief Technology Officer
IonZoft, Inc.
814.742.8030 :: jason@ionzoft.com :: http://IonZoft.com
__________________________________________________________

---

## #9675 — Mehdi Achour — 2004-05-05T22:01:43+00:00

URL: https://externals.io/message/9674#9675 · In reply to: #9674

barfoo (c/p error)

Jason Garber wrote:
> Does it output "barfoo" or "bar"?
> ~Jason
> 
> 
> At 5/5/2004 10:01 PM +0200, Mehdi Achour wrote:
> Hi !
> 
> The manual reads :
> 
> "The name of a constant follows the same rules as any label in PHP. A
> valid constant name starts with a letter or underscore, followed
> by any number of letters, numbers, or underscores. As a regular
> expression, it would be expressed thusly:
> '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]'"
> 
> 
> I know that this is true when trying to echo a constant directly, as the 
> parser raise an error, but you can trick it with a `constant()` call :
> 
> <?php
> 
> define('
> (\ /)
> {=B0_=B0)
> () ()
> ( )( )
> ', 'barfoo');
> 
> echo constant('
> (\ /)
> {=B0_=B0)
> () ()
> ( )( )
> ') . chr(10); // outputs : bar
> 
> Is it a feature or a bug ? :)
> 
> Mehdi Achour
