#20406 [Bgs]: defined() does not work properly within function or class

From: Date: Wed, 13 Nov 2002 13:20:20 +0000
Subject: #20406 [Bgs]: defined() does not work properly within function or class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-24797@lists.php.net to get a copy of this message
 ID:               20406
 User updated by:  fredbird@contactoffice.net
 Reported By:      fredbird@contactoffice.net
 Status:           Bogus
 Bug Type:         Variables related
 Operating System: Windows XP
 PHP Version:      4.2.0
 New Comment:

I was not asking for support nor help. I know that i can replace "if
(defined(NAME))" by "if (NAME)", for example.

I may be wrong about the place where i reported this bug.

But i wonder how you can explain that this is a good behavior for
defined() : how can a constant have a value that you can have access to
and not be defined ?


Previous Comments:
------------------------------------------------------------------------

[2002-11-13 04:58:33] derick@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

------------------------------------------------------------------------

[2002-11-13 04:39:32] fredbird@contactoffice.net

The function defined() always return false within a function or class,
although the value of the constant is still available.

the code :

<?php
define(NAME, "value");
function f() {
     if (defined(NOM)) echo "NOM is defined";
     echo NOM;
}
f();
?>

will print "value" only. Currently tested with EasyPHP running with a
Windows XP computer.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=20406&edit=1



Thread (13 messages)

« previous php.bugs (#24797) next »