#46348 [NEW]: constant docs still say you can't define a resource as a constant, but you can

From: Date: Mon, 20 Oct 2008 20:47:30 +0000
Subject: #46348 [NEW]: constant docs still say you can't define a resource as a constant, but you can
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1218@lists.php.net to get a copy of this message
From: matt at waggoner dot com Operating system: N/A PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: constant docs still say you can't define a resource as a constant, but you can Description: ------------ In the PHP Language Reference section for Constants at http://us3.php.net/constants it says the following: "Only scalar data (boolean, integer, float and string) can be contained in constants. Do not define resource constants." This is false in both 5.2.5 and 5.2.6. Resources (DB connections, file handles, etc.) can be defined as constants and will function. Either the documentation should be changed to match the code, or the code should be fixed to match the documentation. Bug #29534 seems to say that the documentation was fixed a couple of years ago, but the docs seem to still be incorrect. Reproduce code: --------------- foo.php: <?php error_reporting(E_ALL); $link = fopen("foo.php", "r"); var_dump($link); define('FOO', $link); $x = fread(FOO, 10); var_dump($x); echo(gettype(FOO)); fclose(FOO); ?> Expected result: ---------------- I'd expect an error on line 7, telling me that resources cannot be defined as constants. Actual result: -------------- Hello! resource(5) of type (stream) string(10) "Hello! <?p" resource -- Edit bug report at http://bugs.php.net/?id=46348&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46348&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46348&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46348&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46348&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46348&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46348&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46348&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46348&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46348&r=support Expected behavior: http://bugs.php.net/fix.php?id=46348&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46348&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46348&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46348&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46348&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46348&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46348&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46348&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46348&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46348&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46348&r=mysqlcfg

« previous php.doc.bugs (#1218) next »