[英]What's the equivalent in php?
This is zend code. 这是zend代码。 How to convert it to generic PHP?
如何将其转换为通用PHP?
$client = New Zend_Http_Client();
$client->setUri('http://someurl.com/somepage');
$request = $client->request();
if ($request->isSuccessful()) {
//do stuff with the result
}
您将要看一下cURL函数 。
$page = file_get_contents('http://someurl.com/somepage');
In PHP you can just grab the contents of a URI with get_file_contents($url), or even fopen($url, 'r'), etc. 在PHP中,您可以使用get_file_contents($ url)甚至fopen($ url,'r')等获取URI的内容。
You can set stream parameters using stream_context_create(), then use fopen() on that context, if you want to control things like the HTTP request method, user agent, proxy, timeouts, what to do with errors etc. 您可以使用stream_context_create()设置流参数,然后在该上下文上使用fopen()(如果您想控制HTTP请求方法,用户代理,代理,超时,如何处理错误等)。
cURL is an alternative method that can also give you greater control - but then, that adds another dependency. cURL是一种替代方法,也可以为您提供更大的控制权-但是,这会添加另一个依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.