1

trying to put link in variable and calling it as below(as .html extension):

<!DOCTYPE html>
        <html>
        <body>

        <h1>My first PHP page</h1>

        <?php
        $link="https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1";

        ?>

        <video controls="" height="640" width="720">
          <source src="<?php echo $link ?>" type="video/mp4"></source>
          <source src="<?php echo $link ?>" type="video/webm"></source>
          Your browser does not support the video tag.
        </video>
        </body>
        </html>

But I'm getting the unexpexted output on chrome browser:

enter image description here

also i try ruining in .php extension with below code:

<?php
$link='"https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1"';

echo '<video controls="" height="640" width="720">
  <source src=', $link, 'type="video/mp4"></source>
  <source src=', $link, 'type="video/webm"></source>
  Your browser does not support the video tag.
</video>
</body>
</html>';
?>

But This Time output on chrome browser was : Your browser does not support the video tag.

7
  • I'm not very familiar with PHP but it may be possible the scope of $link is only within the first PHP. You would then need to echo the video element as a whole with $link filtered in. Commented May 17, 2020 at 5:01
  • 1
    Works fine here Commented May 17, 2020 at 5:03
  • 2
    I had just copy and pasted and it works fine on mine. Just curious, either you are loading the file on some local server, or are you trying to load the file directly by clicking on that one. Commented May 17, 2020 at 5:05
  • I am using site ground to host my html file. Commented May 17, 2020 at 5:21
  • @sarojshrestha which extension do you use. I have used .html extension Commented May 17, 2020 at 5:22

2 Answers 2

1

You do not mention a variable with , you have to concatinate it if you have another string in the echo. And you must also specify a space after the variable for the type to not be joined with the variable.

Change your code to

<?php
$link='"https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1"';

echo '<video controls="" height="640" width="720">
  <source src='. $link. ' type="video/mp4"></source>
  Your browser does not support the video tag.
</video>
</body>
</html>'; 
Sign up to request clarification or add additional context in comments.

3 Comments

Esta es una buena respuesta. También es buena idea sacar el HTML como tal y mandar a llamar al valor de la variable $link.
@JersonMartínez sorry I cannot understand your language.
Oh, I'm sorry, I speak Spanish, but I want to say that your answer has been good.
0

The call of the variable must be done correctly, as the following:

<?php
    $link = 'https://jia666-my.sharepoint.com/:v:/g/personal/s1pxky0tu_xkx_me/EXvt95V1DmRHg9lrqhd5L0ABby8GhL5XC15qXq1tu87zYw?Download=1';
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Test Video</title>
    </head>
    <body>
        <video controls="" height="640" width="720">
            <source src="<?php echo $link; ?>" type="video/mp4"></source>
            <source src="<?php echo $link; ?>" type="video/webm"></source>
            Your browser does not support the video tag.
        </video>
    </body>
</html>

1 Comment

Now I can see video player on my web page but Now video is not playing. i think player link is not getting link from variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.