ID:               20406
 User updated by:  [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Bogus
 Bug Type:         Variables related
 Operating System: Windows XP
 PHP Version:      4.2.0
 New Comment:

About NAME and NOM : this is a translation problem only (NOM being the
french word for NAME). This piece of code is just an example to show
the bug : please read NAME and NOM as the same constant. I tested this
code and it print _really_ "value".

As for the name of an undefined constant being treated as the string
value of the name, i didn't knew about it.

It just makes me wonder more how are we supposed to check if a constant
is defined within a function or a class, and why we can't althought we
can access the value of this constant. I can't help but thinking that
this _is_ a bug.


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

[2002-11-13 07:35:44] [EMAIL PROTECTED]

Btw. your example is wrong, you check 'NOM' instead of 'NAME'.

Another thing in your script is "defined(NOM)". You should write
"define('NOM')".

And the last: you can't use "if (NAME)" for a replacement of "if
(defined('NAME'))". In this case NAME is evaluted to the string 'NAME'.
The condition is always TRUE  :)

Think about it.

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

[2002-11-13 07:32:26] [EMAIL PROTECTED]

first, read the code you gave us again. it can't produce the output you
claim
it does. it will output "NOM", and possibly an E_NOTICE. clearly, this
is
not a test case for your perceived problem.

second, i don't know what EasyPHP is, but maybe you should file a PR
with its
vendor?



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

[2002-11-13 07:20:19] [EMAIL PROTECTED]

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 ?

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

[2002-11-13 04:58:33] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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

Reply via email to