My PHP class returns a small base64 encoded image, link this:
class Service
{
function getLogo()
{
$image = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c
QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwA";
return 'data:image/png;base64,' . $image;
}
}
Returning the image using json_encode
will add
after each line of $image
:
$service = new Service();
$response = array('name' => $service->getName(), 'logo' => $service->getLogo());
header('Content-type: application/json');
echo json_encode($response);
How to handle it correctly?