CURLOPT_HEADERFUNCTION, couldn't set the function in the class (works in 5.1)
| Bug #36248 | CURLOPT_HEADERFUNCTION, couldn't set the function in the class (works in 5.1) | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2006-02-01 17:39 UTC | Modified: | 2007-01-12 16:38 UTC |
|
||||||||||
| From: | Admin at relax-info dot com | Assigned: | iliaa (profile) | |||||||||||
| Status: | Closed | Package: | cURL related | |||||||||||
| PHP Version: | 4.4.2 | OS: | WIN XP SP2 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2006-02-01 17:39 UTC] Admin at relax-info dot com
Description:
------------
Couldn't set the name of a callback function where the callback function exists in a class, array($this, 'callback_function'). Apache die ...
Reproduce code:
---------------
class CURL
{
var $_ch;
.....
$this->_ch = curl_init();
..
curl_setopt($this->_ch, CURLOPT_HEADERFUNCTION, array($this, '_header_callback'));
..
}
Expected result:
----------------
The name of a callback function can be method of class
array($this, 'callback_function')
Actual result:
--------------
Apache die ...
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-02-01 17:40 UTC] Admin at relax-info dot com
Sorry, callback function example... function _header_callback($ch, $header) { // print_r($header); }[2006-02-01 17:43 UTC] tony2001@php.net
[2006-02-01 17:55 UTC] Admin at relax-info dot com
I am truncate all comment from my class and delete other method than not assign with problem <?php class CURL { var $url; var $header = false; var $returntransfer = false; var $_ch = null; function CURL($url = '') { $this->url = $url; } function init() { $this->_ch = curl_init(); // ... } function execute() { // defauukt setup curl_setopt($this->_ch, CURLOPT_URL, $this->url); // HEADER if ($this->header) { curl_setopt($this->_ch, CURLOPT_HEADER, true); curl_setopt($this->_ch, CURLOPT_HEADERFUNCTION, array($this, '_header_callback'); } // exec $result = curl_exec($this->_ch); // .. return $result; } function _header_callback($ch, $header) { return strlen($header); } } // EXAMPLE --------------------- $url = 'http://www.relax-info.com'; $curl = new CURL($url); if ($curl->init()) { $curl->returntransfer = true; $curl->header = true; $result = $curl->execute(); print_r($result); } else echo $curl->get_error(); ?>[2006-02-02 19:59 UTC] Admin at relax-info dot com
[2007-01-12 16:38 UTC] iliaa@php.net