扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
是不是因为你的数据库相关的字段的长度值不够呀,如果设置长度值不够了的话,会自动给你剪掉的。
我们提供的服务有:网站设计制作、成都网站设计、微信公众号开发、网站优化、网站认证、丰润ssl等。为上千多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的丰润网站制作公司
因为,PHP CURL库默认1024字节的长度不等待数据的返回,所以你那段代码需增加一项配置:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
给你一个更全面的封装方法:
function req_curl($url, $status = null, $options = array())
{
$res = '';
$options = array_merge(array(
'follow_local' = true,
'timeout' = 30,
'max_redirects' = 4,
'binary_transfer' = false,
'include_header' = false,
'no_body' = false,
'cookie_location' = dirname(__FILE__) . '/cookie',
'useragent' = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1',
'post' = array() ,
'referer' = null,
'ssl_verifypeer' = 0,
'ssl_verifyhost' = 0,
'headers' = array(
'Expect:'
) ,
'auth_name' = '',
'auth_pass' = '',
'session' = false
) , $options);
$options['url'] = $url;
$s = curl_init();
if (!$s) return false;
curl_setopt($s, CURLOPT_URL, $options['url']);
curl_setopt($s, CURLOPT_HTTPHEADER, $options['headers']);
curl_setopt($s, CURLOPT_SSL_VERIFYPEER, $options['ssl_verifypeer']);
curl_setopt($s, CURLOPT_SSL_VERIFYHOST, $options['ssl_verifyhost']);
curl_setopt($s, CURLOPT_TIMEOUT, $options['timeout']);
curl_setopt($s, CURLOPT_MAXREDIRS, $options['max_redirects']);
curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
curl_setopt($s, CURLOPT_FOLLOWLOCATION, $options['follow_local']);
curl_setopt($s, CURLOPT_COOKIEJAR, $options['cookie_location']);
curl_setopt($s, CURLOPT_COOKIEFILE, $options['cookie_location']);
if (!empty($options['auth_name']) is_string($options['auth_name']))
{
curl_setopt($s, CURLOPT_USERPWD, $options['auth_name'] . ':' . $options['auth_pass']);
}
if (!empty($options['post']))
{
curl_setopt($s, CURLOPT_POST, true);
curl_setopt($s, CURLOPT_POSTFIELDS, $options['post']);
//curl_setopt($s, CURLOPT_POSTFIELDS, array('username' = 'aeon', 'password' = '111111'));
}
if ($options['include_header'])
{
curl_setopt($s, CURLOPT_HEADER, true);
}
if ($options['no_body'])
{
curl_setopt($s, CURLOPT_NOBODY, true);
}
if ($options['session'])
{
curl_setopt($s, CURLOPT_COOKIESESSION, true);
curl_setopt($s, CURLOPT_COOKIE, $options['session']);
}
curl_setopt($s, CURLOPT_USERAGENT, $options['useragent']);
curl_setopt($s, CURLOPT_REFERER, $options['referer']);
$res = curl_exec($s);
$status = curl_getinfo($s, CURLINFO_HTTP_CODE);
curl_close($s);
return $res;
}
var_dump()打印数组的时候,元素过多,会被隐藏并用省略号代替。
可以使用print_r()。
希望能帮到你。
SQL语句中的变量推荐写完整,比如'$det_name',写成'".$det_name."'或'{$det_name}'
最好检查一下post是否接收到
因为,PHP CURL库默认1024字节的长度不等待数据的返回,所以你那段代码需增加一项配置:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
给你一个更全面的封装方法:
function req_curl($url, $status = null, $options = array())
{
$res = '';
$options = array_merge(array(
'follow_local' = true,
'timeout' = 30,
'max_redirects' = 4,
'binary_transfer' = false,
'include_header' = false,
'no_body' = false,
'cookie_location' = dirname(__FILE__) . '/cookie',
'useragent' = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1',
'post' = array() ,
'referer' = null,
'ssl_verifypeer' = 0,
'ssl_verifyhost' = 0,
'headers' = array(
'Expect:'
) ,
'auth_name' = '',
'auth_pass' = '',
'session' = false
) , $options);
$options['url'] = $url;
$s = curl_init();
if (!$s) return false;
curl_setopt($s, CURLOPT_URL, $options['url']);
curl_setopt($s, CURLOPT_HTTPHEADER, $options['headers']);
curl_setopt($s, CURLOPT_SSL_VERIFYPEER, $options['ssl_verifypeer']);
curl_setopt($s, CURLOPT_SSL_VERIFYHOST, $options['ssl_verifyhost']);
curl_setopt($s, CURLOPT_TIMEOUT, $options['timeout']);
curl_setopt($s, CURLOPT_MAXREDIRS, $options['max_redirects']);
curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
curl_setopt($s, CURLOPT_FOLLOWLOCATION, $options['follow_local']);
curl_setopt($s, CURLOPT_COOKIEJAR, $options['cookie_location']);
curl_setopt($s, CURLOPT_COOKIEFILE, $options['cookie_location']);
if (!empty($options['auth_name']) is_string($options['auth_name']))
{
curl_setopt($s, CURLOPT_USERPWD, $options['auth_name'] . ':' . $options['auth_pass']);
}
if (!empty($options['post']))
{
curl_setopt($s, CURLOPT_POST, true);
curl_setopt($s, CURLOPT_POSTFIELDS, $options['post']);
//curl_setopt($s, CURLOPT_POSTFIELDS, array('username' = 'aeon', 'password' = '111111'));
}
if ($options['include_header'])
{
curl_setopt($s, CURLOPT_HEADER, true);
}
if ($options['no_body'])
{
curl_setopt($s, CURLOPT_NOBODY, true);
}
if ($options['session'])
{
curl_setopt($s, CURLOPT_COOKIESESSION, true);
curl_setopt($s, CURLOPT_COOKIE, $options['session']);
}
curl_setopt($s, CURLOPT_USERAGENT, $options['useragent']);
curl_setopt($s, CURLOPT_REFERER, $options['referer']);
$res = curl_exec($s);
$status = curl_getinfo($s, CURLINFO_HTTP_CODE);
curl_close($s);
return $res;
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流