php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29022 "Warning: Constants may only evaluate to scalar values" on valid constant defin
Submitted: 2004-07-05 20:18 UTC Modified: 2004-07-06 09:12 UTC
From: johfivealive at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0RC3 OS: Fedora Core 2
Private report: No CVE-ID: None
 [2004-07-05 20:18 UTC] johfivealive at hotmail dot com
Description:
------------
using the define() function I get a warning when I don't think I should.

Reproduce code:
---------------
define( "LOGIK_MYSQL_HOST", $config->getMySQLHost() );

where $config->getMySQLHost() returns a string.

The following code makes the warning go away:

define( "LOGIK_MYSQL_HOST", (string) $config->getMySQLHost() );

Expected result:
----------------
define( "LOGIK_MYSQL_HOST", $config->getMySQLHost() );

should not produce a warning

Actual result:
--------------
define( "LOGIK_MYSQL_HOST", $config->getMySQLHost() );

produces the following warning:

"Warning: Constants may only evaluate to scalar values"

even though $config->getMySQLHost() returns a scalar, have to cast to string in order to make the warning go away

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-06 09:12 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is correct behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC