Forums / Craftwork / Client-side / [solved] Construct img tag with javascript and php

GHengeveld
#12437 2009-05-13 23:06
You need to parse the php file as javascript. Try this:
<?php
header('Content-type: text/javascript');
echo "document.write(\"<img src=\"http://www.huddletogether.com/projects/lightbox2/images/image-2.jpg\">\")";
?>
You can use the same technique for dynamically creating images, css files, xml feeds and all kinds of different formats.