Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在变量中以字符串形式传递对象_Php_Json - Fatal编程技术网

Php 在变量中以字符串形式传递对象

Php 在变量中以字符串形式传递对象,php,json,Php,Json,我有这部分代码: public function setAction($action, $params = array()) { $actionUri = strtolower($action); $zanoxAuth = new ApiAuthorization(); $zanoxAuth->setConnectId(__ZANOX_CONNECT_ID); $zanoxAuth->setSecretKey(__ZANOX_SECRET_KEY);

我有这部分代码:

public function setAction($action, $params = array()) {
    $actionUri = strtolower($action);
    $zanoxAuth = new ApiAuthorization();
    $zanoxAuth->setConnectId(__ZANOX_CONNECT_ID);
    $zanoxAuth->setSecretKey(__ZANOX_SECRET_KEY);
    /*
     * Default number of items in the JSON
     * response
     */
    $defaultResults = __ZANOX_JSON_DEFAULT_RESULTS;

    $zanoxAuth->setTimestamp(gmdate("D, d M Y H:i:s T"));
    $timestamp = $zanoxAuth->getTimestamp();
    $nonce = $zanoxAuth->getNonce();
    /*
     * Uri queries concatenation
     */
    $queries = '';
    if (is_array($params) && count($params) > 0)
        foreach ($params as $param => $value)
            $queries .= "&$param=$value";

    /*
     * Getting the first page of the JSON
     * response.
     */
    $results = $this->curlMe(__ZANOX_ENDPOINT . "$actionUri", "?connectid=" . __ZANOX_CONNECT_ID . "$queries&page=0&items=$defaultResults&date=$timestamp&nonce=$nonce&signature=" . $zanoxAuth->getSignature('GET/', $action, $nonce));
    $results = json_decode($results);
    /*
     * Checking if there are more items to get
     * by looping the pages.
     */
    if ($results->total > $defaultResults) {
        $pages = ceil($results->total / $defaultResults);

        for ($i = 1; $i < $pages; $i++) {

            $nonce = $zanoxAuth->getNonce();
            $addJSON = $this->curlMe(__ZANOX_ENDPOINT . "$actionUri", "?connectid=" . __ZANOX_CONNECT_ID . "$queries&page=$i&items=$defaultResults&date=$timestamp&nonce=$nonce&signature=" . $zanoxAuth->getSignature('GET/', $action, $nonce));
            $addJSON = json_decode($addJSON);
            /*
             * Adding JSON items to the main one.
             */
            foreach ((array) $addJSON->programApplicationItems->programApplicationItem as $newItem)
                $results->programApplicationItems->programApplicationItem[] = $newItem;
        }
    }

    $this->action = $results;
    return $this;
}
显然,上述方法不起作用。 我考虑过
var\u dump
var\u export
,但我不确定它们是否有效。 有什么帮助吗?
非常感谢。

使用大括号:
{
}

$results->{$action . "Items"}->{$action . "Item"}[] = $newItem;

$results的输出是什么?
$results->{$action . "Items"}->{$action . "Item"}[] = $newItem;