Help emded video

Discussion in 'PHP' started by xceedbd, Jul 9, 2009.

  1. #1
    Its work:

    <embed src="http://www.xceedbd.com/gallery/admin/uploadedfiles/101.wmv" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>

    ===========
    Its not work (i want like it)

    $videolink="http://www.xceedbd.com/gallery/admin/uploadedfiles/101.wmv";


    <embed src="{$videolink}" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>


    can help me . why its not work.
     
    xceedbd, Jul 9, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <embed src="<?php echo $videolink ?>" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>
    PHP:
     
    wd_2k6, Jul 9, 2009 IP
  3. xceedbd

    xceedbd Well-Known Member

    Messages:
    640
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #3
    Hello,

    thanks for help its works. can u check my code where problem(i want all in php).


    echo '<embed src="{$videolink}" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';


     
    xceedbd, Jul 9, 2009 IP
  4. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The problem with using single quotes is that variables do not get expanded inside them. So $videolink would output as $videolink inside the HTML. A way around this and still to use single quotes is to concatenate some strings together like this:


    
    echo '<embed src="'.$videolink.'" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';
    
    PHP:
    Notice before the variable i close the string, then use a full stop to join the variable together with the strings.

    Or you could use double quotes and the variable will get expanded. However the problem here is we need to escape the " character with a backslash so our echo doesn't get closed accidently.

    
    echo "<embed src=\"$videolink\" width=\"560\" height=\"340\" autostart=\"0\" showcontrols=\"1\" type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/windows/windowsmedia/download/\"> </embed>";
    
    PHP:
    The third option is to use something called HEREDOC which acts like a double quoted string, but without the double quotes so we don't have to escape them. For example:

    
    echo <<<EMBED
    <embed src="$videolink" width="560" height="340" autostart="0" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>
    EMBED;
    
    PHP:
    See Here for more information on strings, including single quotes double quotes and heredoc.
     
    wd_2k6, Jul 9, 2009 IP
  5. xceedbd

    xceedbd Well-Known Member

    Messages:
    640
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #5
    One more thanks "wd_2k6's"
     
    xceedbd, Jul 9, 2009 IP