Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8234225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:24:21+00:00 2026-06-07T18:24:21+00:00

I am a new learner to php. I am trying to retrieve embeded information

  • 0

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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" value="<?php $vari ?>" name="yurl"> <!--$vari-->
    <br>
    <br>
    Height:&nbsp;
    <input type="text" value="<?php $hth ?>" name="yheight"> <!--$hth-->
    <br>
    <br>
    Width:&nbsp;&nbsp;
    <input type="text" value="<?php $wdth ?>" name="ywidth"> <!--$wdth-->
    <br>
    <br>
    Autoplay:&nbsp;
    <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 ('&amp;',$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>');
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:24:22+00:00Added an answer on June 7, 2026 at 6:24 pm

    Try Below Code… Should Work

    <?php
    $vari ='';
    
    if($_POST)
    {
        $vari       = $_POST['yurl'];
        $hth        = $_POST['yheight'];
        $wdth       = $_POST['ywidth'];
        $is_auto    =   0;
    
        $step1 =explode ('v=', $vari);
        $step2 =explode ('&amp;',$step1[1]);
    
        if(isset($_POST['yautop'] ))
        {
            if($_POST['yautop'] == 1)
                $is_auto    =   1;
        }
        $auto1  = '?autoplay='.$is_auto;
        $auto2  = '&autoplay='.$is_auto;
    
    //Iframe code with autoplay
    
    echo htmlentities ('<iframe src="http://ww.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>');
    }
    ?>
    

    Problems were

    1. concatenation operator (.) was missing
    2. variable name was invalid for “$atuo1”
    3. post block was missing.

    Updates

    please replace iframe line with below one (note : one “w” was missing in URL it was “ww”)

    echo htmlentities ('<iframe src="http://www.youtube.com/embed/'.$step2[0].$auto1.'" frameborder="0" width="'.$wdth.'" height="'.$hth.'"></iframe>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new learner of javascript, the following code is from the javascript
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm new to PHP and MySQL and I'm trying to store a users entered
as a learner, and a new one to wordpress, i am trying to learn
The following PHP program replaces the symbols !£$%^& with nulls <?php $string = This
I'm a C++ learner.I'm trying to code a basic C++ project. It's basic automation
I am new to web development, I've learned php, mysql and javascript. I'm trying
I know php well. But I am a very new learner of php framework
I am new learner to jquery/js. I am having difficulties making a scroll tab
Using PDO with prepared statements (I learned from here: http://www.kitebird.com/articles/php-pdo.html ) I'm using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.