Possible Duplicate:
putting print_r results in variable
I'm throwing an exception and trying to include a variable in the exception, like so:
throw new Exception('Oh no, an exception! ' . $variable);
(Where $variable
is an array)
The problem is, this only puts the following in my log file:
On no, an exception! Array
Unfortunately I'm not an expert at PHP, I'm guessing this could mean one of two things:
1) $variable is an empty array
2) $varialbe is an array with data in it, but outputting it as such in an exception does not output all of its contents
Please let me know if 1) is the case here (I hope it isn't though)
However, if 2) is the case, how can I get more information about $variable
? Is it possible to do print_r
or var_dump
inside the exception like follows:
throw new Exception('Oh no, an exception! ' . print_r($variable));
Or will that cause problems?