当前位置: 首页>>代码示例>>PHP>>正文


PHP curl::asPostString方法代码示例

本文整理汇总了PHP中curl::asPostString方法的典型用法代码示例。如果您正苦于以下问题:PHP curl::asPostString方法的具体用法?PHP curl::asPostString怎么用?PHP curl::asPostString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在curl的用法示例。


在下文中一共展示了curl::asPostString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

 /**
  * Arrays are walked through using the key as a the name.  Arrays
  * of Arrays are emitted as repeated fields consistent with such things
  * as checkboxes.
  *
  * @desc Return data as a post string.
  * @param mixed by reference data to be written.
  * @param string [optional] name of the datum.
  * @access public
  */
 function &asPostString(&$theData, $theName = NULL)
 {
     $thePostString = '';
     $thePrefix = $theName;
     if (is_array($theData)) {
         foreach ($theData as $theKey => $theValue) {
             if ($thePrefix === NULL) {
                 $thePostString .= '&' . curl::asPostString($theValue, $theKey);
             } else {
                 $thePostString .= '&' . curl::asPostString($theValue, $thePrefix . '[' . $theKey . ']');
             }
         }
     } else {
         $thePostString .= '&' . urlencode((string) $thePrefix) . '=' . urlencode($theData);
     }
     $xxx =& substr($thePostString, 1);
     return $xxx;
 }
开发者ID:Coding110,项目名称:cbvideo,代码行数:28,代码来源:class.curl.php

示例2: curl

<?php

include_once "class.curl.php";
//
// Create a new instance of the curl class and point it
// at the page to be fetched.
//
$c = new curl("http://www.csworks.com/development/dumpState.php");
//
// By default, curl doesn't follow redirections and this
// page may or may not be available via redirection.
//
$c->setopt(CURLOPT_FOLLOWLOCATION, true);
$c->setopt(CURLOPT_POST, true);
$theFields = array('foo' => '1', 'bar' => array(2, 3, 4), 'baz' => array(array(5, 6), array(7, 8)));
$c->setopt(CURLOPT_POSTFIELDS, $c->asPostString($theFields));
//
// By default, the curl class expects to return data to
// the caller.
//
echo $c->exec();
//
// Check to see if there was an error and, if so, print
// the associated error message.
//
if ($theError = $c->hasError()) {
    echo $theError;
}
//
// Done with the cURL, so get rid of the cURL related resources.
//
开发者ID:CIVICS,项目名称:wp-sched-api,代码行数:31,代码来源:example1.class.curl.php


注:本文中的curl::asPostString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。