|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20406 defined() does not work properly within function or class
Submitted: 2002-11-13 04:39 UTC Modified: 2002-11-13 09:47 UTC
From: fredbird at contactoffice dot net Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.2.0 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: fredbird at contactoffice dot net
New email:
PHP Version: OS:


 [2002-11-13 04:39 UTC] fredbird at contactoffice dot net
The function defined() always return false within a function or class, although the value of the constant is still available.

the code :

define(NAME, "value");
function f() {
     if (defined(NOM)) echo "NOM is defined";
     echo NOM;

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-13 04:58 UTC]
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 as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 14:05:44 2022 UTC