📌  相关文章
📜  file_get_contents url 失败 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:24.110000             🧑  作者: Mango

代码示例2
New file_get_contents that checks valid urls

function get_contents_url($url, $u = false, $c = null, $o = null) {
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            $headers = get_headers($url);
            $status = substr($headers[0], 9, 3);
            if ($status == '200') {
                return file_get_contents($url, $u, $c, $o);
            }
        }
        return false;
    }