Jump to content

php help :( i want to include a url


gameduels

Recommended Posts

<?php
        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "beta.socom.com/en-us/Blog/Ticker");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     
?>

 

try that

file_get_contents($url) is slow. If you want to read the page and extract parts from it then the best method is CURL.

Read the examples http://uk.php.net/manual/en/book.curl.php

 

I scoffed at that when I saw it, didn't think there would be much difference but I've done some tests and CURL is consistently faster over file_get_contents().

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.