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


PHP Json::decode_landmarks方法代码示例

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


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

示例1: load_pset_info

function load_pset_info()
{
    global $ConfSitePATH, $Conf, $PsetInfo, $PsetOverrides, $Opt;
    // read initial messages
    Messages::$main = new Messages();
    $x = json_decode(file_get_contents("{$ConfSitePATH}/src/messages.json"));
    foreach ($x as $j) {
        Messages::$main->add($j);
    }
    // read psets
    $PsetInfo = load_psets_json(false);
    // parse psets
    foreach ($PsetInfo as $pk => $p) {
        if (!is_object($p) || !isset($p->psetid)) {
            continue;
        }
        object_merge_recursive($p, $PsetInfo->_defaults);
        try {
            $pset = new Pset($pk, $p);
            Pset::register($pset);
        } catch (Exception $exception) {
            // Want to give a good error message, so discover where the error is.
            // - create pset landmark object
            $locinfo = (object) array();
            foreach (psets_json_data(false) as $fname => $data) {
                $x = Json::decode_landmarks($data, $fname);
                object_replace_recursive($locinfo, $x);
            }
            $locp = $locinfo->{$pk};
            if (isset($locinfo->_defaults)) {
                object_merge_recursive($locp, $locinfo->_defaults);
            }
            // - lookup exception path in landmark object
            $path = $exception instanceof PsetConfigException ? $exception->path : array();
            for ($pathpos = 0; $pathpos < count($path) && $locp && !is_string($locp); ++$pathpos) {
                $component = $path[$pathpos];
                $locp = is_array($locp) ? $locp[$component] : $locp->{$component};
            }
            // - report error
            if (is_object($locp) && @$locp->__LANDMARK__) {
                $locp = $locp->__LANDMARK__;
            } else {
                if (!is_string($locp)) {
                    $locp = $locinfo->{$pk}->__LANDMARK__;
                }
            }
            Multiconference::fail_message($locp . ": Configuration error: " . $exception->getMessage());
        }
    }
    // read message data
    if (!@$PsetInfo->_messagedefs) {
        $PsetInfo->_messagedefs = (object) array();
    }
    if (!@$PsetInfo->_messagedefs->SYSTEAM) {
        $PsetInfo->_messagedefs->SYSTEAM = "cs61-staff";
    }
    foreach ($PsetInfo->_messagedefs as $k => $v) {
        Messages::$main->define($k, $v);
    }
    // also create log/ and repo/ directories
    foreach (array("{$ConfSitePATH}/log", "{$ConfSitePATH}/repo") as $d) {
        if (!is_dir($d) && !mkdir($d, 02770, true)) {
            $e = error_get_last();
            Multiconference::fail_message("`{$d}` missing and cannot be created (" . $e["message"] . ").");
        }
        if (!file_exists("{$d}/.htaccess") && ($x = file_get_contents("{$ConfSitePATH}/src/.htaccess")) !== false && file_put_contents("{$d}/.htaccess", $x) != strlen($x)) {
            Multiconference::fail_message("Error creating `{$d}/.htaccess`");
        }
    }
    // if any anonymous problem sets, create anonymous usernames
    foreach (Pset::$all as $p) {
        if (!$p->disabled && $p->anonymous) {
            while ($row = Dbl::fetch_first_row(Dbl::qe("select contactId from ContactInfo where anon_username is null limit 1"))) {
                Dbl::q("update ContactInfo set anon_username='[anon" . sprintf("%08u", mt_rand(1, 99999999)) . "]' where contactId=?", $row[0]);
            }
        }
    }
}
开发者ID:benesch,项目名称:peteramati,代码行数:78,代码来源:init.php

示例2: xassert_eqq

if (PHP_MAJOR_VERSION >= 7) {
    xassert_eqq(substr("", 0, 1), "");
} else {
    xassert_eqq(substr("", 0, 1), false);
}
$s = "";
xassert_eqq(@$s[0], "");
// Json tests
xassert_eqq(json_encode(Json::decode("{}")), "{}");
xassert_eqq(json_encode(Json::decode('"\\u0030"')), '"0"');
xassert_eqq(Json::encode("\n"), '"\\n"');
xassert_eqq(Json::encode(""), '"\\u0007"');
xassert_eqq(json_encode(Json::decode('{"1":"1"}')), '{"1":"1"}');
$x = Json::decode_landmarks('{
    "a": ["b", "c"],
    "b": {
        "c": "d"
    }
}', "x.txt");
xassert_match($x->a[0], ",^x.txt:2(?::|\$),");
xassert_match($x->a[1], ",^x.txt:2(?::|\$),");
xassert_match($x->b->c, ",^x.txt:4(?::|\$),");
xassert_match($x->b->__LANDMARK__, ",^x.txt:3(?::|\$),");
// obscure_time tests
$t = $Conf->parse_time("1 Sep 2010 00:00:01");
$t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010");
xassert_eqq($Conf->printableTime($t0), "1 Sep 2010 12pm EDT");
$t = $Conf->parse_time("1 Sep 2010 23:59:59");
$t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010");
xassert_eqq($Conf->printableTime($t0), "1 Sep 2010 12pm EDT");
开发者ID:vaskevich,项目名称:nu-admissions-review,代码行数:32,代码来源:test02.php


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