Undefined Constants behavior in PHP6

php.internals

news.php.net

18 years ago
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

18 years ago
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… On 10/19/07, news.php.net <131.php@cloudyks.org> wrote: > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/

news.php.net

18 years ago
""Alexey Zakhlestin"" <indeyets@gmail.com> a écrit dans le message de news: cd5680a20710190213n7d3f89b4v34e22c07c4c0f896@mail.gmail.com...
> and what's wrong with the following syntax? > > if(defined('DEBUG')) print_r($_SESSION);
I might have a define("DEBUG",$_SERVER["REMOTE_ADDR"]=="myip"); included - on not I know defined exists but, more than the simple "existance" of a constants, sometime, it's "value" might be more important, and auto-string conversion is a wrong behavior i think. of course, i could if(defined("DEBUG") && DEBUG ) ... that's so.... php not. Is there a way to have a " nullyfy_undefined_constants=on" setting ?

Christian Schneider

18 years ago
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

news.php.net

18 years ago
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 ...

Alexey Zakhlestin

18 years ago
On 10/21/07, 131 <131.php@cloudyks.org> wrote:
> 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/