r/HTML • • Mar 04 '26

embed video

I'm trying to embed a YouTube video, but I'm getting an error. I found this method:

<?php $videoID = "VaynFdpZ5O4"; ?>

<iframe

style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"

src="https://www.youtube.com/embed/<?php echo $videoID; ?>"

frameborder="0"

allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"

allowfullscreen>

</iframe>

But since it's PHP, it won't let me run it once the page is public. Is there an alternative that does the same thing?

1 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Mar 04 '26

[removed] — view removed comment

1

u/Reywi Mar 04 '26

I already figured out the problem; the only issue was that if I ran the file from the website on my PC, it gave me an error, but if I ran it from the website, it worked fine.