Jump to content

Error Debugging


mattspriggs28

Recommended Posts

Hi,

 

I'm wanting to debug a couple of errors on a live site.

 

I have a form that is filled in and the data is stored in an array, as well as the validation error messages before anything is submitted to the database.

 

What I'm wanting to do is fire the array data in an email to myself so I can see what has been submitted in the form in order to see where a particular error may be occuring.

 

I understand that to output the values of an array you need to use print_r(), but how do I add this output to a variable in order to slot it in the body of an email?

 

Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/208273-error-debugging/
Share on other sites

print_r() has a second parameter called 'return' and it's a true/false of whether it will print the output or return it. Here's an example taken from the PHP manual page for print_r()

 

<?php
$b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z'));
$results = print_r($b, true); // $results now contains output from print_r
?>

 

Link to comment
https://forums.phpfreaks.com/topic/208273-error-debugging/#findComment-1088531
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.