Consider the custom error function:
function customError($errNumber, $errString, $errFile, $errLine, $errContext)
The $errContext provides a lot of useful information to debug with. How can I put this into a string and mail it?
My first attempt:
$mailContent = "Error \n";
foreach($errContext as $errType => $stringOrArray)
{
$mailContent .= "\n$errType =>";
if(is_array($stringOrArray))
{
$mailContent .= " Array\n";
foreach($stringOrArray as $key => $value)
{
$mailContent .= "\n $key => $value";
}
$mailContent .= "\n";
}
else
$mailContent .= " $stringOrArray";
}
- This does not work with objects (yet).
- This is not very elegant.
Is there an easy way that I do not know about?
How about simply:
If you supply
TRUEas the second argument toprint_r(), it returns the output as a string instead of writing it to the output buffer.