I am trying to load an iframe (youtube embed specifically) in a bootstrap modal. If I place the iframe code directly into the modal, it loads fine. But when I echo out the iframe code through a variable, it will not load. I can echo out the iframe outside of the modal, and it loads fine, it's just within the modal that the iframe will not load.
This works CASE 1
<div class="modal fade" id="video-modal" tabindex="-1" role="dialog" aria-labelledby="video-modalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<iframe width="1280" height="720" src="https://www.youtube.com/embed/9Gb7M7S6T7U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
This will also load the iframe CASE 2
<?php
echo $video;
?>
<div class="modal fade" id="video-modal" tabindex="-1" role="dialog" aria-labelledby="video-modalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
</div>
</div>
</div>
</div>
This does not work CASE 3
<div class="modal fade" id="video-modal" tabindex="-1" role="dialog" aria-labelledby="video-modalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<?php
echo $video;
?>
</div>
</div>
</div>
</div>
Any idea why?
For context, this is in Wordpress 5, PHP7, and the value of $video is being called from an ACF field.