function getDataURI($image, $mime = '') {
return 'data: ' . (function_exists('mime_content_type') ? mime_content_type($image) : $mime) . ';base64,' . base64_encode(file_get_contents($image));
}
$image = 'image.jpg';
$embed_image = getDataURI($image);
// Put it on screen
<img src="<?=$embed_image;?>" />
The main advantage of using Data URIs to embed almost anything onto your webpages is to minimise HTTP requests.