如何修复此PHP代码

如何修复此PHP代码,php,geturl,Php,Geturl,上面说有个错误 我试图让它在playlist.m3u8?wmsAuthSign=和“我在mylink.com/file.php?f=之后放的任何页面上,然后在GETURL代码中的www.linkhere.com/之后放上whatever,这样它就可以在linkhere.com/whatever页面上的playlist.m3u8?wmsAuthSign=和”之间进行抓取(如果有意义的话) 代码如下: <?php function getURL($u){ $u = fi

上面说有个错误

我试图让它在playlist.m3u8?wmsAuthSign=和“我在mylink.com/file.php?f=之后放的任何页面上,然后在GETURL代码中的www.linkhere.com/之后放上whatever,这样它就可以在linkhere.com/whatever页面上的playlist.m3u8?wmsAuthSign=和”之间进行抓取(如果有意义的话)

代码如下:

<?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=", '"');
?>

你不认为将代码分解成步骤和顺序很有意义,直到你可以在睡觉时编程吗?此外,将代码分解成步骤有助于你看得更清楚,也有助于你学习。随着一个人的进步,他发现自己甚至可以编写一个复杂的算法(学徒需要30行)在一行中…但在此之前…建议学徒从构建块开始,然后构建,甚至以复杂的方式完成(只要简单、漫长、枯燥的方式有效,并产生更多的洞察力)


“它说有一个错误”,错误是什么?解析错误:语法错误,意外',需要标识符(T_字符串)或变量(T_变量)或数字(T_NUM_字符串)在第22行的/home/ygwtljbj/public_html/fs2.php中,第22行是$stream行您提供的代码示例中甚至没有22行,因此错误可能来自其他原因,或者您没有向我们显示您的实际代码。第22行是代码中的$stream行您不能在双引号中使用双引号,您需要对它们进行转义,或者在单引号中,
getURL
中的字符串给出了您的语法错误。解析错误:语法错误,意外“,”(T_CONSTANT_ENCAPSED_string)在/home/ygwtljbj/public_html/fs2.php的第24行,这是$stream,请使用更多信息进行编辑。仅限代码和“尝试此”答案是不鼓励的,因为它们不包含可搜索的内容,也不解释为什么有人应该“尝试这个”。应该是这样。。。。
$url = (!isset($_GET["f"])) ? "filehere.php" : htmlspecialchars($_GET["f"]);
$stream = GetStringBetween(getURL("www.linkhere.com/".$url),"playlist.m3u8?wmsAuthSign=", '"');
<?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=", '"');
?>
    <?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=', '\"');
    ?>