PHP - echo variable into JavaScript
I am trying to put a value within some javascript code like so:
<?
$page = "test";
echo ('<script id="template-download" type="text/x-jquery-tmpl">
<tr class="template-download{{if error}} ui-state-error{{/if}}">
{{if erro开发者_如何学运维r}}
<td class="name" style="display: none;">${name}</td>
<td class="size" style="display: none;">${sizef}</td>
.....etc...
{{if thumbnail_url}}
<img src="Img/');
$page;
echo('.jpg">
{{/if}}
.....etc....
</script>');
?>
And the end value looks like this:
{{if thumbnail_url}}
<img src="Img/.jpg">
{{/if}}
and it doesn't put the value? What am i missing???
David
You're not echoing page.
echo $page;
thats because you're using single quotes so echo doesnt evaluates $vars and like Joe said, particulary $page is not being echoed
精彩评论