php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37811 define not using toString on objects
Submitted: 2006-06-15 00:27 UTC Modified: 2006-07-09 22:45 UTC
From: php at trancer dot nl Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.* OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at trancer dot nl
New email:
PHP Version: OS:

 

 [2006-06-15 00:27 UTC] php at trancer dot nl
Description:
------------
PHP is using toString on most places to cast objects to string. However define is not doing this. This seems somewhat of an oddity as objects are casted in other functions aswell.

Possible fix to this problem was provided by bjori:

http://php.is/bugs/toString/define.call.toString.patch.txt

Reproduce code:
---------------
<?php

class foo 
{

	function __toString()
	{
		
		return "bar";
		
	}
	
}

$foo = new foo();

define('COWBELL', $foo);

?>

Expected result:
----------------
It being properly defined using the toString function.

Actual result:
--------------
Warning: Constants may only evaluate to scalar values in test.php on line 15

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-09 22:45 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC