来自php函数的javasctipt代码中的echo函数

时间:2019-09-25 10:03:43

标签: javascript php

<?php
// error_reporting(0);

function crawl_page($url) {

    $dom = new DOMDocument('1.0');

    // Loading HTML content in $dom
    @$dom->loadHTMLFile($url);

    // Selecting all image i.e. img tag object
    $anchors = $dom -> getElementsByTagName('source');

    // Extracting attribute from each object
    foreach ($anchors as $element) {

        // Extracting value of src attribute of
        // the current image object
        $src = $element -> getAttribute('src');

        // Extracting value of alt attribute of
        // the current image object
        $alt = $element -> getAttribute('alt');

        // Extracting value of height attribute
        // of the current image object
        $height = $element -> getAttribute('height');

        // Extracting value of width attribute of
        // the current image object
        $width = $element -> getAttribute('width');

        // Given Output as image with extracted attribute,
        // you can print value of those attributes also

echo $src;

    }
}

crawl_page("url");

?>

我有验证码 $ src是要在javascript代码中插入的网址 回声$ src;在函数内部工作并回显链接

但是外部功能不起作用

我要在Javasript代码中插入$ src变量结果

        <script>
            (function () {
          var video = document.querySelector('#player');

          if (Hls.isSupported()) {
            var hls = new Hls();
            hls.loadSource('**i want to insert here**');                hls.attachMedia(video);
            hls.on(Hls.Events.MANIFEST_PARSED,function() {
              video.play();
            });
          }

          plyr.setup(video);
        })();
        </script>

但是它不起作用 有人可以建议我吗?

0 个答案:

没有答案