-1

エラーがあるとのこと

私は、mylink.com/file.php?f=whatever の後に置いたページで、playlist.m3u8?wmsAuthSign= と " の間で取得しようとします GETURL コードで、playlist.m3u8?wmsAuthSign=linkhere.com/whateverページの"の間を取得します (意味がある場合)

コードは次のとおりです。

<?php
    function getURL($u){
        $u = file_get_contents("http://{$u}");
        return $u != false ? $u : "";
    }
    function GetStringBetween($string, $start, $finish){
        $string = " ".$string;
        $position = strpos($string, $start);
        if ($position == 0) return "";
        $position += strlen($start);
        $length = strpos($string, $finish, $position) - $position;
        return substr($string, $position, $length);
    }
    $stream = GetStringBetween(getURL("www.linkhere.com/<?=!isset($_GET["f"]) ? "filehere.php" : htmlspecialchars($_GET["f"])?>"),"playlist.m3u8?wmsAuthSign=", '"');
?>
4

3 に答える 3

1
<?php
    function getURL($u){
        $u = file_get_contents("http://{$u}");
        return $u != false ? $u : "";
    }
    function GetStringBetween($string, $start, $finish){
        $string = " ".$string;
        $position = strpos($string, $start);
        if ($position == 0) return "";
        $position += strlen($start);
        $length = strpos($string, $finish, $position) - $position;
        return substr($string, $position, $length);
    }


$url = (!isset($_GET["f"])) ? "filehere.php" : htmlspecialchars($_GET["f"]);
$stream = GetStringBetween(getURL("www.linkhere.com/".$url),"playlist.m3u8?wmsAuthSign=", '"');
?>

このように?

于 2016-07-22T05:36:10.933 に答える
0

眠っている間にプログラミングできるようになるまで、コードをステップとシーケンスに分解することは非常に理にかなっていると思いませんか? さらに、コードをステップに分割すると、物事がより明確になり、学習にも役立ちます。進歩するにつれて、複雑なアルゴリズム (見習いの場合は 30 行を必要とする) を 1 行で書いていることに気付くことさえあります。複雑な方法で実行することもできます (単純で長くて退屈な方法が機能し、多くの洞察が得られる限り)...

    <?php
        function getURL($u){
            $u        = file_get_contents("http://{$u}");
            return ($u  != false) ? $u : "";
        }

        function GetStringBetween($string, $start, $finish){
            $string      = " ".$string;
            $position    = strpos($string, $start);

            if ($position == 0){ return "";}

            $position  += strlen($start);
            $length     = strpos($string, $finish, $position) - $position;

            return substr($string, $position, $length);
        }

        $f      = ( !isset($_GET["f"]) ) ? "filehere.php" : htmlspecialchars(trim($_GET["f"]);
        $url        = "www.linkhere.com/{$f}";
        $theURI = getURL($url); 

        $stream    = GetStringBetween($theURI,'playlist.m3u8?wmsAuthSign=', '\"');
    ?>
于 2016-07-22T07:31:39.083 に答える