I am a new learner to php. I am trying to retrieve embeded information from youtube videos URLs. I was originally following the code from this SITE but unfortunately the author doesn’t provide access to actual code.
I am having difficulties extracting the php variable values so that i can get the embedded video code.
The htmlentities echo is returning this errorsyntax error, unexpected T_CONSTANT_ENCAPSED_STRING
source: SITE
<html>
<form method="post" action="">
URL:
<input type="text" value="<?php $vari ?>" name="yurl"> <!--$vari-->
<br>
<br>
Height:
<input type="text" value="<?php $hth ?>" name="yheight"> <!--$hth-->
<br>
<br>
Width:
<input type="text" value="<?php $wdth ?>" name="ywidth"> <!--$wdth-->
<br>
<br>
Autoplay:
<input type="checkbox" value="<?php $auto1; $auto2; ?>" name="yautop"> <!--$auto1 $auto2-->
<br>
<br>
<input type="submit" value="Generate Embed Code" name="ysubmit">
</form>
</html>
php code for getting youtube url info
<?php
$vari ='';
$step1 =explode ('v=', $vari);
$step2 =explode ('&',$step1[1]);
$auto1='?autoplay=1';
$auto2='&autoplay=1';
//Iframe code with autoplay
echo htmlentities ('<iframe src="http://www.youtube.com/embed/'.$step2[0].$auto1'"
frameborder="0" width="'.$wdth.'" height="'.$hth.'"></iframe>';
//embed code with autoplay
echo htmlentities ('<embed width="'.$wdth.'" height="'.$hth.'"
type="application/x-shockwave-flash" src="http://www.youtube.com/v/'.$step2[0].$auto2'"
wmode="transparent" embed="" /></embed>');
?>
Try Below Code… Should Work
Problems were
Updates
please replace iframe line with below one (note : one “w” was missing in URL it was “ww”)