954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

curl webpage into string variable help

i'm trying this below but it isn't working, the page is coming up blank ..

<?php
$url = 'http://www.realgm.com';
function get_url_contents($url){
        $crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;
}

?>
MDanz
Junior Poster
152 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

i'm trying this below but it isn't working, the page is coming up blank ..

<?php
$url = 'http://www.realgm.com';
function get_url_contents($url){
        $crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_URL,$url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;
}

?>


That all you got or is there more?

OS_dev
Junior Poster
110 posts since Feb 2010
Reputation Points: 10
Solved Threads: 14
 

call the function after the function definition and use the below code

$ret=get_url_contents('http://www.realgm.com';);
echo $ret;

now the result will be seen

RoseAug
Newbie Poster
1 post since Mar 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You