Я создаю собственный помощник в ./application/helpers Однако я получаю эту ошибкуПользовательские Помощники в CodeIgniter
Невозможно загрузить запрошенные хелперы файл/curl_helper
Это код в мой помощник файла:
function send(array $request, $url, $method)
{
//Validating if the required extensions are installed or not
if(!function_exists('json_encode')) return false;
if(!function_exists('curl_init')) return false;
//Converting the array into required json format
$request = json_encode($request);
//Setting header required for requests
$header[] = "Content-type: application/json";
$header[] = "Content-length: ".strlen($request) . "\r\n";
//If the request method is get append the data into requests header
if($method == 'GET' or $method == 'get') $header[] = $request;
//Initializing curl
$ch = curl_init();
//Setting curl options for request
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
//If the request method is post add the data we need to enable post
//request and define the data in post fields
if($method == 'POST' or $method == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
}
//Executing the curl request and storing the result in a variable
$result = curl_exec($ch);
//Closing curl conneciton
curl_close($ch);
return json_decode($result);
}
И я загружая его в моей библиотеке, как:
$this->loader =& get_instance();
$this->loader->load->helper('curl');
Скажите, где я делаю неправильно?
UPDATE:
После попытки слишком много вещей, когда я поставил функцию в той же библиотеке, где я хочу, чтобы использовать я обнаружил, что есть ошибка в строке
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
когда я комментировать это функция линии работает нормально. Я не знаю, где ошибка, пожалуйста, помогите мне. И насколько я думаю, это причина ошибки загрузчика.
Вы навели своего помощника 'curl_helper.php'? –
Offcourse и я пробовал в любом случае средства, префикс префикса подкласса и его удаление. –
попробуйте его без загрузчика '$ this-> load-> helper ('curl');' –