|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-04-22 08:28 UTC] dv at josheli dot com
Description: ------------ http://www.php.net/manual/en/language.constants.php "Only scalar data (boolean, integer, float and string) can be contained in constants." http://www.php.net/manual/en/function.mysql-connect.php "resource mysql_connect ( ... )" According to the documentation, "Expected result" is an E_NOTICE error or something, but I guess the "Actual result" below implies that a mysql link "resource" is actually an integer (4?). perhaps the documentation in either of the two places listed above, or in the define() man page, should reflect this fact? Reproduce code: --------------- $dbLink = mysql_connect($dbServerName, $dbUser, $dbPassword); define('DB_LINK',$dbLink); var_dump(DB_LINK); echo gettype(DB_LINK); Expected result: ---------------- see above. Actual result: -------------- resource(4) of type (mysql link) resource PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 06:00:02 2025 UTC |
Maybe there an engine error here. Take a look at this code: <? $tidy = new tidy; define('aa', $tidy); print_r(AA); ?> outputs: Warning: Constants may only evaluate to scalar values in C:\cygwin\home\Nuno\constants.php on line 3 Call Stack: 0.0012 1. {main}() C:\cygwin\home\Nuno\constants.php:0 0.0014 2. define('aa', class tidy { public $errorBuffer = NULL; public $va lue = NULL }) C:\cygwin\home\Nuno\constants.php:3 Notice: Use of undefined constant AA - assumed 'AA' in C:\cygwin\home\Nuno\constants.php on line 4 Call Stack: 0.0012 1. {main}() C:\cygwin\home\Nuno\constants.php:0 Variables in local scope: $tidy = class tidy { public $errorBuffer = NULL; public $value = NULL } AA 1) It seems that in fact this works, but outputs a couple of errors and echoes the name of the constant, too. Need a fix in the engine. 2) constants are suposed to scalar data or they may have objects/resources?