Ove*_*Lex 52
使用curl php库:http://php.net/manual/en/book.curl.php
直接示例:CURL_EXEC:
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
And*_*y E 28
正如其他人所提到的,PHP的cURL函数将允许您执行高级HTTP请求.您还可以使用file_get_contents
访问REST API:
$payload = file_get_contents('http://api.someservice.com/SomeMethod?param=value');
Run Code Online (Sandbox Code Playgroud)
从PHP 5开始,您还可以创建流上下文,以允许您更改标头或将数据发布到服务.
最简单的方法是使用FOpen或FOpen的Wrappers之一.
$page = file_get_contents("http://www.domain.com/filename");
Run Code Online (Sandbox Code Playgroud)
这确实需要FOpen,一些Web主机禁用,一些Web主机将允许FOpen,但不允许访问外部文件.您可能想要检查运行脚本的位置,以查看是否可以访问External FOpen.
如果您的意思是..从该页面重定向到另一个页面,该功能非常简单
header("Location:www.google.com");
Run Code Online (Sandbox Code Playgroud)