php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79380 define() function not working with typecasting
Submitted: 2020-03-13 13:29 UTC Modified: 2020-03-13 13:34 UTC
From: amit000790 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.4.3 OS: Ubuntu 18.04
Private report: No CVE-ID: None
 [2020-03-13 13:29 UTC] amit000790 at gmail dot com
Description:
------------
define() function not working with typecasting

For Ex.
define("BLANK_OBJECT", (object) [] );

var_dump( BLANK_OBJECT );

---------------
Output
---------------
Warning: Constants may only evaluate to scalar values, arrays or resources in [...][...] on line 4

Warning: Use of undefined constant BLANK_OBJECT - assumed 'BLANK_OBJECT' (this will throw an Error in a future version of PHP) in [...][...] on line 6
string(12) "BLANK_OBJECT"

Test script:
---------------
define("BLANK_OBJECT", (object) [] );
var_dump( BLANK_OBJECT );

Expected result:
----------------
stdClass Object
(
)

Actual result:
--------------
Warning: Constants may only evaluate to scalar values, arrays or resources in [...][...] on line 4

Warning: Use of undefined constant BLANK_OBJECT - assumed 'BLANK_OBJECT' (this will throw an Error in a future version of PHP) in [...][...] on line 6
string(12) "BLANK_OBJECT"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-13 13:34 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2020-03-13 13:34 UTC] cmb@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC