ID: 36461 Updated by: [EMAIL PROTECTED] Reported By: mgkimsal at gmail dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: All PHP Version: Irrelevant New Comment:
Wow, I misread your results assuming this wasn't possible. But it is! The following bug report has been reopened so marking this duplicate as bogus. http://bugs.php.net/bug.php?id=29534 Feel free to discuss there. Previous Comments: ------------------------------------------------------------------------ [2006-02-21 00:47:21] mgkimsal at gmail dot com The documentation I'm referring to is in define(). http://us2.php.net/define This gives the impression that you can only define a constant based on what is in the 'constant' page that you reference. Running the code I provided indicates that a resource handle can be defined into a constant, which is counter to the documentation, or unclear at best. ------------------------------------------------------------------------ [2006-02-20 22:38:08] [EMAIL PROTECTED] >From the manual (php.net/constants): Only scalar data (boolean, integer, float and string) can be contained in constants. What documentation are you referring to? A resource type is certainly not scalar. ------------------------------------------------------------------------ [2006-02-20 14:44:48] mgkimsal at gmail dot com Description: ------------ I realize this is 18 months late, but why is this bogus? It's not only a winxp problem - this happens on all platforms I've tried (well, win and linux). Nor is this only a PHP5 problem - it's a problem in the 4 series as well (haven't tested 3). Either the docs should be changed, or the code behaviour should be changed. I'm in favor of the latter. While the 'resource' might be constant - "Resource id #4" might always be "Resource id #4", the state of that resource might change (file reading problems, db connection problems, etc.). If the value (or the functional state) of something can change, that's not really 'constant', is it? Also, I'm not sure how resource ID numbers are allocated, so this situation might not happen, but in a resource-intense app, might there be a chance of using a resource, closing it, opening a new one, and getting the same 'id' #? I only found out about this recently, but it seems wrong, and certainly goes against the documentation. Reproduce code: --------------- <?php $x = mysql_connect('localhost','rt_mgk_user','rt_mgk_pass','rt_mgk'); define('FOO',$x); if (is_resource(FOO)) { echo 'foo is a resource'; } else { echo 'foo is not a resource'; } ?> Expected result: ---------------- foo is not a resource Actual result: -------------- foo is a resource ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36461&edit=1