php.net |  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
 [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 :

<?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.

Patches

besho (last revision 2023-10-24 06:24 UTC by beshob998 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-13 04:58 UTC] 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.
 [2023-10-24 06:24 UTC] beshob998 at gmail dot com
The following patch has been added/updated:

Patch Name: besho
Revision:   1698128684
URL:        https://bugs.php.net/patch-display.php?bug=20406&patch=besho&revision=1698128684
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC