在PHP中使用CURL发布以“@”开头的文本数据 [英] Using CURL in PHP to post text data starting with "@"

查看:158
本文介绍了在PHP中使用CURL发布以“@”开头的文本数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CURL在PHP中发布数据,如下所示:

  curl_setopt($ ch,CURLOPT_POSTFIELDS,$ args) 

其中$ args - 参数数组。



问题是其中一个参数的值以@开头。根据CURL文档,这意味着我要发送一个文件。这在我的情况不是真的。
因此,我得到以下错误消息:失败创建formpost数据。



有一种方法来指定每当我想发送一个文件或

>解决方案

你可以使用百分比编码吗?这样你的'@'符号将是%40和CURL不会打乱他们。我们通常对所有帖子字段进行百分比编码。



http://en.wikipedia.org/wiki/Percent-encoding


I use CURL to post data in PHP like this:

curl_setopt($ch, CURLOPT_POSTFIELDS, $args);

where $args - array of parameters.

The problem is that one of the parameters has its value starting with "@". And according to CURL documentation, that means that I'm going to send a file. Which is not true in my case. As a result I get the following error message: failed creating formpost data.

Is there a way to specify whenever I want to send a file or "@" is just a regular character that is part of some value?

Thanks, Gena

解决方案

Could you use percent encoding instead? That way your '@' symbols would be %40 and CURL won't mess with them. We usually percent encode all our post fields.

http://en.wikipedia.org/wiki/Percent-encoding

这篇关于在PHP中使用CURL发布以“@”开头的文本数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆