cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl and ampersands

From: Jeff Philapy <linux_at_altahost.com>
Date: Wed, 7 Jan 2004 03:18:00 -0800

The code below works but it confuses the ampersands in my $body variable
text with the ampersands in the CURLOPT_POSTFIELDS. I need to be able to use
the ampersands in my text. How do I work around this?

<?php
$c = curl_init('myurl_and_cgi_to_post_to');

$body = "This is my test and in it I need to use ampersands. & or &";

curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, 'name=test&body=' . $body);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$page = curl_exec($c);
curl_close($c);
?>

As an example:

$body = "This is my test. An Ampersand like this & breaks the above code. Or
an ampersand like this &amp; breaks the above code.";

I need to know: is there another way to put ampersands in html that actually
does not in any form use the ampersand symbol in the source code? Or is
there away to use a delimiter different then the ampersand? Or possibly
another workaround.

Thanks much,
Jeff

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2004-01-07