# Undefined Constants behavior in PHP6

- Thread: https://externals.io/message/32871
- Original archive: https://news-web.php.net/php.internals/32871
- Started by news.php.net on 2007-10-19T08:41:38+00:00
- Messages: 5
- 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

---

## #32871 — news.php.net — 2007-10-19T08:41:38+00:00

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

I was wondering if someone already think about modifying the actual behavior 
of undefined constants in php6.
I'm desperate with some

if(DEBUG) print_r($_SESSION);

- and lot others case -

Is there a possibility undefined constants ( strings ) return "null" :x ?
I do not think it's a mistake, since echo "{$array[foo]}" is not good and 
"{$array['foo']}" is

131

---

## #32873 — Alexey Zakhlestin — 2007-10-19T09:13:49+00:00

URL: https://externals.io/message/32871#32873 · In reply to: #32871

and what's wrong with the following syntax?

if(defined('DEBUG')) print_r($_SESSION);

I don't think there's a need to change anything here…


> I was wondering if someone already think about modifying the actual behavior
> of undefined constants in php6.
> I'm desperate with some
>
> if(DEBUG) print_r($_SESSION);
>
> - and lot others case -
>
> Is there a possibility undefined constants ( strings ) return "null" :x ?
> I do not think it's a mistake, since echo "{$array[foo]}" is not good and
> "{$array['foo']}" is
>
> 131
>
> --
> 
> 
>
>


-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

---

## #32875 — Christian Schneider — 2007-10-19T09:46:40+00:00

URL: https://externals.io/message/32871#32875

news.php.net wrote:
> I might have a define("DEBUG",$_SERVER["REMOTE_ADDR"]=="myip"); included - 
> on not

Just make sure you always set DEBUG, shouldn't be too hard if your code 
has any structure ;-)

- Chris

---

## #32881 — 131.php@cloudyks.org — 2007-10-20T20:44:24+00:00

URL: https://externals.io/message/32871#32881 · In reply to: #32875

It's not always a structural issue :/
I'm sure non defined string interpretation is a bad thing

I'm not a php core writter, but it have to be, even a little, more 
complicated to use undefined constants as there "string" value, than as 
"null"

Maybe i'm the only one thinking that way.
I'll try to handle this by myself with parsekit & runkit ...

---

## #32900 — Alexey Zakhlestin — 2007-10-21T07:51:58+00:00

URL: https://externals.io/message/32871#32900 · In reply to: #32881

> It's not always a structural issue :/
It is

> I'm sure non defined string interpretation is a bad thing
it is definitely a bad thing, but it is a documented bad thing and I
believe there are still some scripts which rely on this

> I'm not a php core writter, but it have to be, even a little, more
> complicated to use undefined constants as there "string" value, than as
> "null"
>
> Maybe i'm the only one thinking that way.
> I'll try to handle this by myself with parsekit & runkit ...

use of undefined constants produces a `E_NOTICE` 
you can catch these in error-handler while debugging and fix the
structure of code accordingly.

-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/
