|
Posted by Andy Jeffries on 05/22/06 17:12
On Thu, 18 May 2006 19:06:35 -0700, lawrence k wrote:
>> Ever tried to post info to another page strictly through PHP?
>>
>> Curl takes care of some of the overhead. Obviously you can do anything
>> in PHP that you can in Curl. Curl just makes things easier.
>
> Yes. I used fsocketopen. I think it took less than 20 lines of code, so
> how much simpler could Curl make it?
$ch = curl_init("http://www.domain.cxm/foo.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_exec($ch);
curl_close($ch);
So, 25% of the LOC.
Plus you automatically get session cookie handling. How many extra lines
of code would that be? Oh, by the way, we've moved this page to an HTTPS
host now, how many extra lines of code would that be?
Don't get me wrong, there are a large number of times when I've happily
re-invented the wheel if I have a really specific idea of the way
something should work (even if there's a PEAR class to do it), but I make
it a rule to look at it first before making a conscious decision to
duplicate effort.
In this case, there's no way I'd overlook a PHP built in and rewrite it
myself using sockets.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
Navigation:
[Reply to this message]
|