php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40373 calling "print()" on an ArrayObject fails silently.
Submitted: 2007-02-06 16:23 UTC Modified: 2007-02-07 08:25 UTC
From: james at thundermonkey dot net Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.2.0 OS: WinXP SP2
Private report: No CVE-ID: None
 [2007-02-06 16:23 UTC] james at thundermonkey dot net
Description:
------------
When attempting to "print()" an ArrayObject (rather than "print_r()") no ouput is returned, no errors are displayed and the script aborts silently.

Reproduce code:
---------------
<?php
$x = new ArrayObject(array('a', 'b'));
print $x;
print "Reached this point!";
exit();

/* in php.ini: error_reporting  =  E_ALL | E_STRICT */
?>

Expected result:
----------------
*Some kind of error message saying that the ArrayObject couldn't be converted to a string followed by:*

Reached this point!

Actual result:
--------------
(no output at all)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-06 17:27 UTC] tony2001@php.net
Catchable fatal error: Object of class ArrayObject could not be converted to string 
 [2007-02-06 18:23 UTC] james at thundermonkey dot net
Running the following code:

<?php
trigger_error("Triggered", E_RECOVERABLE_ERROR);
?>

results in:

Warning: Invalid error type specified in C:\dump\trigger.php on line 2

so E_RECOVERABLE_ERROR is not defined in this version?

PHP 5.2.0, build date: Nov 2 2006 11:50:55
 [2007-02-06 18:27 UTC] tony2001@php.net
That's right, you cannot use it in userspace.
 [2007-02-06 19:16 UTC] james at thundermonkey dot net
Ok, so back to the original code snippet - I'm confused why there are no error messages being displayed when it's executed. I don't get anything like "Object of class ArrayObject could not be converted to string", but it is what I'm expecting. It's just horrible blankness. Nothing in error log file either.

Also, it's not actually related to ArrayObject alone, but rather all objects, so the following also fails silently:

<?php
$x = new StdClass();
print $x;
print "OK"; // We don't get this far.
?>
 [2007-02-07 08:25 UTC] james at thundermonkey dot net
Resolved.

Poking around in a convoluted VirtualHost block, I came across the following:

...
php_value error_reporting 2047
...

Obviously overriding anything in php.ini! Apologies for the bogus report.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 14:01:34 2025 UTC