php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47751 define() allows resources as values
Submitted: 2009-03-23 00:31 UTC Modified: 2009-03-23 11:20 UTC
From: mgkimsal at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mgkimsal at gmail dot com
New email:
PHP Version: OS:

 

 [2009-03-23 00:31 UTC] mgkimsal at gmail dot com
Description:
------------
This is a duplicate of http://bugs.php.net/bug.php?id=29534 which is 4.5 years old now.  The comment 3 years ago was that the XML docs had been updated, but the current PHP doc page for define still shows that "only scalar and null values are allowed. Scalar values are integer, float, string or boolean values."  This is still wrong.  Either the docs need to be updated to indicate resources are allowed, or PHP needs to be updated to throw an error when a resource is define()d.

Reproduce code:
---------------
---
From manual page: function.define
---
<?php
$f = fopen(__FILE__,"r");
define('x',$f);
fclose($f);
$g = fread(x,400);
echo $g;
echo x;
echo constant('x');

Expected result:
----------------
some sort of error

Actual result:
--------------
the program prints out itself (because I'm read the fopen of __FILE__)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-23 11:20 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Seems like I forgot to add that to the define page while I updated the constants.syntax page.

But yes, resource constants are allowed but it was decided to leave the implementation as it is now for BC.
 [2020-02-07 06:10 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b508f205be1af5e97687022982e6ac258b5ddd7a
Log: Fixed #47751 (define() allows resources as values)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC