PHP如何实现Post和Get请求处理?
- 内容介绍
- 文章标签
- 相关推荐
本文共计375个文字,预计阅读时间需要2分钟。
封装PHP+cUrl库,主要提供post、get方法,支持cookie和session。
phpclass CurlHelper{ private $curl;
public function __construct() { $this->curl=curl_init(); $this->_setopt(CURLOPT_RETURNTRANSFER, true); $this->_setopt(CURLOPT_HEADER, true); $this->_setopt(CURLOPT_FOLLOWLOCATION, true); }
public function post($url) { // 实现post方法 }
public function get($url) { // 实现get方法 }
private function setopt($option, $value) { curl_setopt($this->curl, $option, $value); }
public function close() { curl_close($this->curl); }}
封装PHP cUrl库。本文共计375个文字,预计阅读时间需要2分钟。
封装PHP+cUrl库,主要提供post、get方法,支持cookie和session。
phpclass CurlHelper{ private $curl;
public function __construct() { $this->curl=curl_init(); $this->_setopt(CURLOPT_RETURNTRANSFER, true); $this->_setopt(CURLOPT_HEADER, true); $this->_setopt(CURLOPT_FOLLOWLOCATION, true); }
public function post($url) { // 实现post方法 }
public function get($url) { // 实现get方法 }
private function setopt($option, $value) { curl_setopt($this->curl, $option, $value); }
public function close() { curl_close($this->curl); }}
封装PHP cUrl库。
