CURL get_content vs PHP file_get_contents

Skythrust

Member
Jul 9, 2019
133
7
Hiya,

I would like to use CURL get_content with the same parameters als file_gets_content

Like below, I have add some parameters at file_get_contents (FALSE, NULL, 20, 100)

Code:
$URL= file_get_contents('http://192.168.2.126', FALSE, NULL, 20, 100);

And I would like to use that for my CURL get_content,

Code:
$URL= 'http://192.168.2.126';

function get_content($URL){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $URL);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
}

I have tried to add these in my echo and inside my function but I can't realize this. My goal is to show text/parameters from a different (external) page.
Any advise?

Thanks!
 

Higoka

Active Member
Dec 16, 2018
174
74
does it have to be curl? why not something simple like this:
PHP:
$content = file_get_contents('http://example.com');
// do something with $content
 

Skythrust

Member
Jul 9, 2019
133
7
it does just make sure allow_url_fopen is enabled in your php.ini
i think its even enabled by default
Thanks!

I'm getting these 2 errors;

Warning: file_get_contents(): stream does not support seeking in D:\Applications\Websites\OA\test\inc\variables.php on line 6
Warning
: file_get_contents(): Failed to seek to position 30 in the stream in D:\Applications\Websites\OA\test\inc\variables.php on line 6

Code:
$content = file_get_contents('http://192.168.2.126', FALSE, NULL, 30, 100);
 

Higoka

Active Member
Dec 16, 2018
174
74
what are you trying to do? im not sure about the last two params (30, 100)

try this
PHP:
$content = file_get_contents('http://192.168.2.126');
$text = substr($content, 30, 100);
 

Users who are viewing this thread

Top