This seems to work as expected:
<?php
$string="http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&alt=json-in-script&callback=youtubeFeedCallback";
?>
<script type="text/javascript" src="<?php echo $string; ?>"></script>
with the output of:
<script type="text/javascript" src="http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&alt=json-in-script&callback=youtubeFeedCallback"></script>
Edit: in your source code on pastebin, you seem to have:
$string = "http://gdata.youtube.com/feeds/api/videos/" . $id ."?v=2&alt=json-in-script&callback=youtubeFeedCallback";
which contains &
in the place of &
which would stop the link working. Was this somethign that pastebin did or was it in your original code?
You can't send HTML codes to the URL window and expect it to work the same way as if it was in a HTML body.
The following code (just edited $id
as I am not putting anything in GET and modified &
symbols gave:
<html>
<head>
<?php
//$id = $_GET['id'];
$id=0;
$string = "http://gdata.youtube.com/feeds/api/videos/" . $id ."?v=2&alt=json-in-script&callback=youtubeFeedCallback";
?>
<title></title>
</head>
<body>
<?php echo $string; ?><br>
<script type="text/javascript" src="<?php echo $string; ?>"></script>
Had the output of:
<title></title>
</head>
<body>
http://gdata.youtube.com/feeds/api/videos/0?v=2&alt=json-in-script&callback=youtubeFeedCallback<br>
<script type="text/javascript" src="http://gdata.youtube.com/feeds/api/videos/0?v=2&alt=json-in-script&callback=youtubeFeedCallback"></script>