What's the equivalent in php?
This is zend code. How to convert it to generic PHP?
$client = New Zend_Http_Client();
$client->setUri('http://someurl.com/somepage');
$request = $client->request();
if ($request->isSuccessful()) {
开发者_运维问答 //do stuff with the result
}
You'll want to look at the cURL functions.
$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.
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.
cURL is an alternative method that can also give you greater control - but then, that adds another dependency.
精彩评论