I'm working on web-service.
I'm trying to catch error. My problematic code is:
try
{
$query = "UPDATE Users
SET
Latitude=?,
Longitude=?,
Address=?,
LocationTimestamp=?
WHERE Id=?";
$stmt = $this->link->prepare($query);
$stmt->bind_param('ddssi', $Latitude, $Longitude, $Address, $LocationTimestamp, $Id);
$stmt->execute();
$affected_rows = $stmt->affected_rows;
}
catch(Exception $exc)
{
file_put_contents("log/error.txt",$exc->getMessage());
}
I expected, that catch block will catch all errors and PHP will not produce any errors on output. However - on output I see something like this:
Warning: Creating default object from empty value in /srv/webservice/server.php on line 119
I want to avoid any HTML on output, because this is web-service and I have JSON interpreter on client side.
My question is:
How to debug service like this, when I have no access to PHP output? I would like to redirect all errors, warnings etc. to file.