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


PHP json::pretty方法代码示例

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


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

示例1: encodeData

 function encodeData()
 {
     $this->data = $this->pretty_output ? json::pretty($this->data) . "\n" : json_encode($this->data);
     if ($this->data === null) {
         $this->throwJSONError(false, 'Failed to encode $data (' . gettype($this->data) . ') as JSON');
     }
 }
开发者ID:rsms,项目名称:gitblog,代码行数:7,代码来源:JSONStore.php

示例2: rsp_err

function rsp_err($msg = '', $status = '400 Bad Request', $bt = null)
{
    $rsp = array('message' => $msg);
    if ($bt) {
        $rsp['bt'] = $bt;
    }
    rsp_ok(json::pretty(array('error' => $rsp)), $status);
}
开发者ID:rsms,项目名称:gitblog,代码行数:8,代码来源:data.php

示例3: sync_site_state

 static function sync_site_state()
 {
     ignore_user_abort(true);
     # verify repo setup, which also makes sure the repo setup (hooks, config,
     # etc) is up to date:
     self::repair_repo_setup();
     # assure gitblog submodule is set up
     $dotgitmodules = gb::$site_dir . '/.gitmodules';
     if (!is_file($dotgitmodules) || !preg_match('/\\[submodule[\\s\\t ]+"gitblog"\\]/', file_get_contents($dotgitmodules))) {
         self::add_gitblog_submodule();
     }
     # read id of HEAD and current branch
     $gb_branch = 'master';
     $gb_head = '0000000000000000000000000000000000000000';
     try {
         $branches = trim(git::exec('branch --no-abbrev --verbose --no-color', null, gb::$dir . '/.git', gb::$dir));
         foreach (explode("\n", $branches) as $line) {
             if (!$line) {
                 continue;
             }
             if ($line[0] === '*') {
                 if (strpos($line, '(no branch)') !== false) {
                     $line = preg_split('/[ \\t]+/', $line, 5);
                     $gb_branch = null;
                     $gb_head_id = $line[3];
                 } else {
                     $line = preg_split('/[ \\t]+/', $line, 4);
                     $gb_branch = $line[1];
                     $gb_head_id = $line[2];
                 }
                 break;
             }
         }
     } catch (GitError $e) {
         gb::log(LOG_WARNING, 'failed to read branch info for gitblog -- git: %s', $e->getMessage());
     }
     # no previous state?
     if (!gb::$site_state) {
         gb::$site_state = array();
     }
     # Set current values
     gb::$site_state['url'] = gb::$site_url;
     gb::$site_state['version'] = gb::$version;
     gb::$site_state['posts_pagesize'] = gb::$posts_pagesize;
     # appeard in 0.1.3:
     gb::$site_state['gitblog'] = array('branch' => $gb_branch, 'head' => $gb_head_id);
     # Write site url for hooks
     $bytes_written = file_put_contents(gb::$site_dir . '/.git/info/gitblog-site-url', gb::$site_url, LOCK_EX);
     # Encode site.json
     $json = json::pretty(gb::$site_state) . "\n";
     $path = gb::$site_dir . '/data/site.json';
     # create data/ ?
     if (!is_dir(gb::$site_dir . '/data')) {
         mkdir(gb::$site_dir . '/data', 0775);
         chmod(gb::$site_dir . '/data', 0775);
     }
     # Write site.json
     $bytes_written += file_put_contents($path, $json, LOCK_EX);
     chmod($path, 0664);
     gb::log(LOG_NOTICE, 'wrote site state to %s (%d bytes)', $path, $bytes_written);
     return $bytes_written;
 }
开发者ID:rsms,项目名称:gitblog,代码行数:62,代码来源:gb_maint.php

示例4: json_rsp

 static function json_rsp($data = null, $status = '200 OK', $exit = true, $pretty = true)
 {
     if ($data !== null) {
         $data = $pretty ? json::pretty($data) . "\n" : json_encode($data);
     } else {
         $data = '';
     }
     self::abrupt_rsp($data, $status, 'application/json; charset=utf-8', $exit);
 }
开发者ID:rsms,项目名称:gitblog,代码行数:9,代码来源:gb_admin.php


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