I am coding my own var_dump to meet certain requirements which probably only apply to me and have a problem.
The code checks for objects, arrays, etc and finally gets to a stage where it reckons it is left with a number, a string or a boolean.
Of course, a string can actually be a serialized variable, so I want to heck for that ...
if (is_string($variable))
{
// check if it is serialzed; if so, unserialize & dump as an array, \
// with a suitable header indicating that it was serialized
try
{
$old_error_level= error_reporting(E_ALL ^ E_NOTICE);
$unserialized_varaible = @unserialize($variable);
$result .= my_dump($unserialized_varaible, ... <some params>); // recursive call
$old_error_level= error_reporting($old_error_level);
}
catch(Exception $e) // Treat it as a string
{
$old_error_level= error_reporting($old_error_level);
$result .= GetHtmlForSimpleVariable($variable, ... <some params>);
}
}
But, what I get when trying to dump a simple, non-serialized, string is
Problem type Notice "unserialize()
[<a href='function.unserialize'>function.unserialize</a>]:
Error at offset 0 of 14 bytes" at line 362 in file my_dump.php<br><br>
Update: the point there is that I want to suppress that E_NOTICE when a string is not a serialized string. I had thought that the @
on @unserizlize()
would do that, but ...
If the string is serialized then everything is hunky dory. If not, then not.