|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25158 Var_Dump raise a warning if found a resource
Submitted: 2003-08-19 16:48 UTC Modified: 2003-08-20 03:50 UTC
From: maka3d at yahoo dot com dot br Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.3.2 OS: WIN XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
39 + 27 = ?
Subscribe to this entry?

 [2003-08-19 16:48 UTC] maka3d at yahoo dot com dot br
Var_Dump raise a warning at line 750 of var_dump.php file
if the display function found a resource using VAR_DUMP_DISPLAY_MODE_HTML_TABLE

Reproduce code:
require_once 'Var_Dump.php';
$resource = mysql_pconnect('localhost','root','');

Var_Dump::display( $resource ); // this works

Var_Dump::display( $resource , '' , VAR_DUMP_DISPLAY_MODE_HTML_TABLE); // this doesn't work

Expected result:
write resource as the code without HTML do

Actual result:
WARNING: htmlspecialchars() expects parameter 1 to be string, resource given


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-19 17:26 UTC] pear dot neufeind at speedpartner dot de
In all other functions in this class expect _formatTableHTML the variable itself is concatenated to other strings the type is automagically typecasted to a string.

Fixing this in function _formatTableHTML is easy:

old: htmlspecialchars($array[VAR_DUMP_ARRAY_VALUE])
new: htmlspecialchars((string) $array[VAR_DUMP_ARRAY_VALUE])

simply typecast yourself and everything works fine.

If you want to do it the elegant way you could test if
$array[VAR_DUMP_ARRAY_VALUE] is_object and in that case do a get_class($array[VAR_DUMP_ARRAY_VALUE]). But since this is done automatically by PHP and it's handled the same way (auto-type-conversion) in other parts of this class, too, simply typecasting to string seems to work fine.
 [2003-08-19 17:29 UTC]
see last comment - sorry
 [2003-08-20 03:50 UTC]
Frederic Poeydomenge integrated my patch in the new release 0.4
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 20 12:03:35 2022 UTC