私はphpの新しい学習者です。YouTube ビデオの URL から埋め込み情報を取得しようとしています。私はもともとこのサイトのコードに従っていましたが、残念ながら作成者は実際のコードへのアクセスを提供していません。
埋め込まれたビデオ コードを取得できるように、php 変数の値を抽出するのが困難です。
htmlentities エコーがこのエラーを返していますsyntax error, unexpected T_CONSTANT_ENCAPSED_STRING
ソース:サイト
<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>
YouTube の URL 情報を取得するための PHP コード
<?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>');
?>