Programming + Design

Switching from allow_url_fopen to CURL PDF Print E-mail
Written by Brett Brewer   
Wednesday, 03 June 2009

You may have notice that my site was displaying an error message across the top of the screen recently, due to my web host disabling "allow_url_fopen" in the PHP config (php.ini), which broke my Skype class that shows my Skype status. Today I finally got around to fixing it. Here's the code change I made, which should be easy to use as an example if you run into similar problems:

 Old Code:

$num = file($this->url);
$this->status = $num[0];


New Code:

// Establish a cURL handle
$ch = curl_init($this->url);
// Set cURL options
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL request
$num = curl_exec($ch);

// Close the cURL session.

$this->status = $num[0];

A little more code to do the same thing as before, but apparently this is safer than keeping "allow_url_fopen" enabled. 

Last Updated ( Wednesday, 03 June 2009 )
< Prev   Next >


Who's Online

We have 1 guest online

© 2017
Joomla! is Free Software released under the GNU/GPL License.