DIsplaying a php variable inside js : I must start by saying I'm a complete js noob but I've spent a big portion of today solving this with all the answers I found here + google, couldn't get it done, so I decided to ask for a direct help.

Basically, I want to embed an Youtube video in a php page. The videoid variable is defined into the php page but I cannot make the js display that variable.

  

    <script>
      // Load the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/player_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    
      var player;
      function onYouTubePlayerAPIReady() {
        player = new YT.Player('ytplayer', {
          height: '460',
          width: '760',
          videoId: '<? echo $var;>'
        });
      }
    </script>

The $var variable is present globally within the php file but it doesn't work. I also declared a variable within the js, with no success. What am I doing wrong?