How can I test for a serialized variable? Without throwing E_NOTICE if string is not serialized
<p>I am coding my own var_dump to meet certain requirements which probably only apply to me and have a problem.</p>

<p>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. </p>

<p>Of course, a string can actually be a serialized variable, so I want to heck for that ...  </p>

<pre><code>if (is_string($variable))
{
   // check if it is serialzed; if so, unserialize &amp; 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, ... &lt;some params&gt;); // 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, ... &lt;some params&gt;);
   }
}
</code></pre>

<p>But, what I get when trying to dump a simple, non-serialized, string is </p>

<pre><code>Problem type Notice "unserialize() 
  [&lt;a href='function.unserialize'&gt;function.unserialize&lt;/a&gt;]:
  Error at offset 0 of 14 bytes" at line 362 in file my_dump.php&lt;br&gt;&lt;br&gt;
</code></pre>

<hr>

<p>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 <code>@</code>on <code>@unserizlize()</code> would do that, but ...</p>

<p>If the string is serialized then everything is hunky dory. If not, then not.</p>
