我需要把这个的$ id值到JavaScript的下方如何将PHP变量的值传递给Javascript代码?
PHP帮助:
<?php
$id = NULL;
$username = 'YouTube';
$xml = simplexml_load_file(sprintf('http://gdata.youtube.com/feeds/base/users/%s/uploads?alt=rss&v=2&orderby=published', $username));
if (! empty($xml->channel->item[0]->link))
{
parse_str(parse_url($xml->channel->item[0]->link, PHP_URL_QUERY), $url_query);
if (! empty($url_query['v']))
$id = $url_query['v'];
}
echo $id; // Outputs the video ID.
?>
JS:需要的$ id值--->“我需要的价值去在这里”
<script type="text/javascript">
$('document').ready(function() {
var options = { videoId: 'I need the value to go right here', start: 3 };
$('#video1').tubular(options);
});
</script>
什么问题呢?为什么不''<?php echo $ id; ?>在javascript中? – EaterOfCode
它工作!对不起,我是一个新手,并且是所有这些的新手。谢谢!!! EaterOfCorpses – nowthatsmint
没关系:)有人需要学习一段时间:) – EaterOfCode