|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-07 16:02 UTC] nlopess@php.net
[2006-02-21 17:07 UTC] philip@php.net
[2006-03-07 01:21 UTC] vrana@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 19:00:01 2025 UTC |
Description: ------------ A resource can be defined as a constant: e.g. define("my_file",fopen(...)); or STDIN, STDOUT, STDERR in CLI mode. In the "Constants" manual section constant values are constrained to scalars only. "Only scalar data (boolean, integer, float and string) can be contained in constants." However, a resource is not a scalar (is_scalar returns false). Moreover, a NULL can be used as a value of a constant. It's a mess, isn't it? IMHO a resource should be a scalar. Such a change is acceptable since there is a notice in the is_scalar() function description which allows it: "Note: is_scalar() does not consider resource type values to be scalar as resources are abstract datatypes which are currently based on integers. This implementation detail should not be relied upon, as it may change." And there should be stated in the constants section of the manual that a NULL can be also a constant (don't forget to correct an error message which is reported if one tries to define a constant with a value being e.g. an array or object).