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


PHP json::encode方法代码示例

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


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

示例1: throwJson

/**
* 抛出json回执信息
* 
* @access public
* @param string $message 消息体
* @param string $charset 信息编码
* @return void
*/
function throwJson($message, $charset = NULL)
{
    /** 设置http头信息 */
    header('content-Type: application/json; charset=' . (empty($charset) ? 'UTF-8' : $charset), true);
    echo json::encode($message);
    /** 终止后续输出 */
    exit;
}
开发者ID:Ethan0814,项目名称:STBlog,代码行数:16,代码来源:json_helper.php

示例2: batch

 function batch($params)
 {
     $result = $this->request('POST', '/batch', [], $params);
     $array = [];
     foreach ($result as $name => $value) {
         $array[$name] = json::decode(json::encode($value));
         # TODO: Replace with fast solution
     }
     return $array;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:10,代码来源:api.php

示例3: prepStr

 function prepStr($str)
 {
     global $CONF_use_utf, $langEncodings, $nativeLanguage;
     if (!$CONF_use_utf) {
         require_once dirname(__FILE__) . '/../ConvertCharset/ConvertCharset.class.php';
         $NewEncoding = new ConvertCharset();
         $str = $NewEncoding->Convert($str, $langEncodings[$nativeLanguage], "utf-8", $Entities);
     }
     $newStr = json::encode($str);
     if ($newStr[0] == '"') {
         return substr($newStr, 1, -1);
     } else {
         return $newStr;
     }
     // return str_replace('"','\"',$str);
 }
开发者ID:Peter2121,项目名称:leonardoxc,代码行数:16,代码来源:CL_json.php

示例4: fetch_action

 function fetch_action() {
     $id = front::post('id');
     $tpl = str_replace('#','',$id);
     $tpid = $tpl;
     $tpl = str_replace('_d_','/',$tpl);
     $tpl = str_replace('_html','.html',$tpl);
     $tpl = str_replace('_css','.css',$tpl);
     $tpl = str_replace('_js','.js',$tpl);
     $res = array();
     $res['content'] = file_get_contents(TEMPLATE .'/'.config::get('template_dir') .'/'.$tpl);
     $res['content'] = preg_replace('%</textarea%','<&#47textarea',$res['content']);
     $res['content'] = "<textarea rows=\"20\" cols=\"78\" id=\"{$tpid}_content\" style=\"font-family: Fixedsys,verdana,宋体; font-size: 12px;\" name=\"{$tpid}_content\">$res[content]</textarea>";
     echo json::encode($res);
     exit;
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:15,代码来源:template_admin.php

示例5: logincheck

<?php

require_once 'inc.config.php';
logincheck();
if (isset($_POST['order_units'])) {
    addProductions('ship,defence', $_POST['order_units']);
    $arrJson = array(array('eval', "\$('f_order_units').reset();"), array('html', 'div_productionlist', getProductionList('ship,defence')), array('msg', 'Productions added!'));
    foreach (db_select_fields('planet_resources', 'resource_id,amount', 'planet_id = ' . PLANET_ID) as $iResourceId => $iAmount) {
        $arrJson[] = array('html', 'res_amount_' . $iResourceId, nummertje($iAmount));
    }
    exit(json::encode($arrJson));
}
_header();
?>
<div class="header">Production<?php 
if ((int) $GAMEPREFS['havoc_production']) {
    echo ' (<b style="color:red;">HAVOC!</b>)';
}
?>
</div>

<br />

<?php 
echo getProductionForm('ship,defence');
?>

<br />

<div id="div_productionlist">
<?php 
开发者ID:rudiedirkx,项目名称:Pornstars,代码行数:31,代码来源:production.php

示例6: json

 function json_encode($value)
 {
     $json = new json();
     return $json->encode($value);
 }
开发者ID:sxau-web-team,项目名称:wish-web,代码行数:5,代码来源:Boot.php

示例7: dbfield_select_action

 function dbfield_select_action() {
     $res=array();
     $res['content']='&nbsp;&nbsp;没有可以进行替换的字段。';
     $table=front::post('stable');
     if(@class_exists($table)) {
         $table=new $table;
         $_fields=array();
         foreach($table->getFields() as $field) {
             if(preg_match('/text|var/',$field['type']) &&!preg_match('/^[a-zA-Z_]+$/',lang($field['name'])))
                 $_fields[]=$field['name'];
         }
         $fields=array(0=>null);
         foreach($_fields as $field) $fields[$field]=lang($field);
         if(count($_fields)>0)
             $res['content']='&nbsp;&nbsp;字段=>'.form::select('sfield',0,$fields,'style="font-size:16px"');
     }
     $res['id']='fieldlist';
     echo json::encode($res);
     exit;
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:20,代码来源:database_admin.php

示例8: run_test

 public static function run_test()
 {
     $array = array('foo' => array('bar', 'baz' => array(1, 2, 3, 4, 5, 6, 7), array('a', 'b', 'c', 'd')), 'bar' => array(5, 4, 3, 2, 1), 'oop' => 'oxxxbj&%$ect oriented programming', 'baz' => array(1, 2, 3, 4, 5, array('a', array(1, 2, 3), 'b', 'x' => 'c')));
     header('content-type: text/plain');
     $json = new json();
     $string = $json->encode($array);
     $converted = $json->decode($string);
     print_r($converted);
 }
开发者ID:laiello,项目名称:xiv,代码行数:9,代码来源:json.php

示例9: json_encode

 function json_encode($array) {
     return json::encode($array);
 }
开发者ID:jiangsuei8,项目名称:public_php_shl,代码行数:3,代码来源:front_class.php

示例10: define

define('SB_POSTED', (int) $GAMEINFO['small_blind'] <= (int) @mysql_result(@MQuery("SELECT bet FROM mpp_players WHERE gid = " . GAMEID . " AND uid = " . SMALLBLINDID . ";"), 0));
define('BB_POSTED', (int) $GAMEINFO['big_blind'] <= (int) @mysql_result(@MQuery("SELECT bet FROM mpp_players WHERE gid = " . GAMEID . " AND uid = " . BIGBLINDID . ";"), 0));
// var_dump(BIGBLINDID);
// Wie is er aan de beurt
define("UID_AAN_DE_BEURT", wie_is_aan_de_beurt());
// Zorgen dat UID Online blijft
MQuery("UPDATE mpp_players SET online=UNIX_TIMESTAMP(NOW()) WHERE uid = " . (int) $_SESSION['mpp']['uid'] . " AND gid = " . (int) $_SESSION['mpp']['gid'] . ";");
// En Offline players op OUT zetten
MQuery("UPDATE mpp_players SET in_or_out = 'out' WHERE gid = " . (int) $_SESSION['mpp']['gid'] . " AND online < " . (time() - 31) . ";");
/** HTML - STATUS WINDOW **/
if (isset($_GET['mode']) && $_GET['mode'] == 'status') {
    // Update keepalive
    MQuery("UPDATE mpp_players SET online = " . time() . " WHERE uid = " . (int) $_SESSION['mpp']['uid'] . " AND gid = " . (int) $_SESSION['mpp']['gid'] . ";");
    $arrGame = mysql_fetch_assoc(MQuery('SELECT * FROM mpp_games WHERE id = ' . (int) $_SESSION['mpp']['gid'] . ';'));
    require_once 'inc.cls.json_php5.php';
    echo json::encode(array('game' => array('dealer' => (int) $arrGame['dealer'], 'turn' => (int) wie_is_aan_de_beurt(), 'pot' => (double) $arrGame['pot'], 'last_win' => (int) $arrGame['last_win']), '_status' => UID_AAN_DE_BEURT == $_SESSION['mpp']['uid'] ? 'IT\'S YOUR TURN' : '...', 'seat_1' => printSeat(1), 'seat_2' => printSeat(2), 'seat_3' => printSeat(3), 'seat_4' => printSeat(4), 'seat_5' => printSeat(5), 'seat_6' => printSeat(6), 'seat_7' => printSeat(7), 'center_flop' => Print_Flop()));
    exit;
    // Let page know it's your turn
    if (UID_AAN_DE_BEURT == $_SESSION['mpp']['uid']) {
        exit('IT\'S YOUR TURN');
    }
    exit('...');
}
/** PROCESS - SMALL BLIND **/
if (isset($_POST['small_blind']) && SMALLBLINDID == USERID && READY_GAME) {
    $bet = (int) $GAMEINFO['small_blind'];
    // Posting small blind
    MQuery("UPDATE mpp_players SET bet = bet+" . $bet . ", balance = balance-" . $bet . ", ready_for_next_round = 'no' WHERE gid='" . GAMEID . "' AND uid='" . USERID . "';");
    MQuery("UPDATE mpp_games SET pot=pot+" . $bet . " WHERE id='" . GAMEID . "' AND player_turn='" . USERID . "';");
    // Beurt naar volgende speler
    beurt_naar_volgende_speler(USERID);
开发者ID:rudiedirkx,项目名称:Games,代码行数:31,代码来源:132.php

示例11: edit

 public function edit()
 {
     $this->assertLoggedIn();
     $this->set('area', 'bots');
     try {
         //how do we find them?
         if ($this->args('id')) {
             $bot = new Bot($this->args('id'));
         } else {
             throw new Exception("Could not find that bot.");
         }
         //did we really get someone?
         if (!$bot->isHydrated()) {
             throw new Exception("Could not find that bot.");
         }
         if (!$bot->isMine()) {
             throw new Exception("You cannot view that bot.");
         }
         $this->setTitle('Edit Bot - ' . $bot->getName());
         $wizard = new Wizard('bot', $this->args());
         if (!$this->args('setup')) {
             $wizard->disableWizardMode();
         }
         // Create our forms
         $infoForm = $this->_createInfoForm($bot);
         $queuesForm = $this->_createQueueForm($bot);
         $slicingForm = $this->_createSlicingForm($bot);
         $driverForm = $this->_createDriverForm($bot);
         // Add them to the wizard
         $wizard->add("Information / Details", $infoForm);
         $wizard->add("Queues", $queuesForm);
         $wizard->add("Slicing Setup", $slicingForm);
         $wizard->add("Driver Configuration", $driverForm);
         //handle our forms
         if ($infoForm->checkSubmitAndValidate($this->args())) {
             $bot->set('name', $infoForm->data('name'));
             $bot->set('manufacturer', $infoForm->data('manufacturer'));
             $bot->set('model', $infoForm->data('model'));
             $bot->set('electronics', $infoForm->data('electronics'));
             $bot->set('firmware', $infoForm->data('firmware'));
             $bot->set('extruder', $infoForm->data('extruder'));
             $bot->save();
             Activity::log("edited the information for bot " . $bot->getLink() . ".");
         } else {
             if ($queuesForm->checkSubmitAndValidate($this->args())) {
                 $sql = "DELETE FROM bot_queues WHERE bot_id = ?";
                 db()->execute($sql, array($bot->id));
                 $priority = 1;
                 $used = array();
                 foreach ($this->args() as $key => $value) {
                     if (substr($key, 0, 6) === "queue-" && $value != 0) {
                         if (in_array($value, $used)) {
                             continue;
                         } else {
                             $used[] = $value;
                         }
                         $sql = "INSERT INTO bot_queues VALUES(?, ?, ?)";
                         $data = array($value, $bot->id, $priority);
                         $priority++;
                         db()->execute($sql, $data);
                     }
                 }
             } else {
                 if ($slicingForm->checkSubmitAndValidate($this->args())) {
                     $bot->set('slice_engine_id', $slicingForm->data('slice_engine_id'));
                     $bot->set('slice_config_id', $slicingForm->data('slice_config_id'));
                     $config = $bot->getDriverConfig();
                     $config->can_slice = (bool) $slicingForm->data('can_slice');
                     $bot->set('driver_config', json::encode($config));
                     $bot->save();
                     Activity::log("edited the slicing info for bot " . $bot->getLink() . ".");
                 } else {
                     if ($driverForm->checkSubmitAndValidate($this->args())) {
                         $bot->set('oauth_token_id', $driverForm->data('oauth_token_id'));
                         $bot->set('driver_name', $driverForm->data('driver_name'));
                         //create and save our config
                         $config = $bot->getDriverConfig();
                         $config->driver = $bot->get('driver_name');
                         if ($bot->get('driver_name') == 'dummy') {
                             if ($this->args('delay')) {
                                 $config->delay = $this->args('delay');
                             }
                         } elseif ($bot->get('driver_name') == 'printcore' || $bot->get('driver_name') == 's3g') {
                             $config->port = $this->args('serial_port');
                             $config->port_id = $this->args('port_id');
                             $config->baud = $this->args('baudrate');
                         }
                         //did we get webcam info?
                         if ($this->args('webcam_device')) {
                             if (!isset($config->webcam)) {
                                 $config->webcam = new stdClass();
                             }
                             $config->webcam->device = $this->args('webcam_device');
                             if ($this->args('webcam_id')) {
                                 $config->webcam->id = $this->args('webcam_id');
                             }
                             if ($this->args('webcam_name')) {
                                 $config->webcam->name = $this->args('webcam_name');
                             }
                             if ($this->args('webcam_brightness')) {
//.........这里部分代码省略.........
开发者ID:eric116,项目名称:BotQueue,代码行数:101,代码来源:bot_edit.php

示例12: getOptions

 /**
  * Returns the processed js options
  * @return array
  */
 public function getOptions()
 {
     return $this->options ? json::encode($this->options) : '{}';
 }
开发者ID:davidjeddy,项目名称:yii2-leaflet-draw-plugin,代码行数:8,代码来源:Draw.php

示例13: run

    public function run()
    {
        if (isset($this->htmlOptions['id'])) {
            $id = $this->htmlOptions['id'];
        }
        if (isset($this->htmlOptions['name'])) {
            $name = $this->htmlOptions['name'];
        }
        //        if ($this->hasModel()) {
        //            echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
        //        }
        echo Html::hiddenInput($this->attribute, $this->value, $this->htmlOptions);
        $fileManagerOptions = ['csrfTokenName' => Yii::$app->request->csrfParam, 'csrfToken' => yii::$app->request->csrfToken, 'pickerSelector' => '#' . $this->fileManagerContainerId . 'Uploader', 'createFileRoute' => Url::toRoute('//fileManager/createFile'), 'createDirectoryRoute' => Url::toRoute('//fileManager/createDirectory'), 'deleteFileRoute' => Url::toRoute('//fileManager/deleteFile'), 'deleteDirectoryRoute' => Url::toRoute('//fileManager/deleteDirectory'), 'listFile' => Url::toRoute('//fileManager/listFile'), 'fileIdInputSelector' => '#' . $id];
        $gOptions = json::encode($fileManagerOptions);
        $js = <<<EOD
jQuery('#{$this->fileManagerContainerId}').fileManager({$gOptions});
EOD;
        $this->getView()->registerJs($js, \yii\web\View::POS_END);
        return $this->render('fileManager/views/view', ['fileManagerContainerId' => $this->fileManagerContainerId]);
    }
开发者ID:yuzic,项目名称:yii2-webfilemanager,代码行数:20,代码来源:FileManagerWidget.php

示例14: logincheck

<?php

require_once 'inc.config.php';
logincheck();
if (isset($_POST['x'], $_POST['y'], $_POST['z'], $_POST['message'])) {
    $iPlanetId = db_select_one('galaxies g, planets p', 'p.id', 'p.galaxy_id = g.id AND g.x = ' . (int) $_POST['x'] . ' AND g.y = ' . (int) $_POST['y'] . ' AND p.z = ' . (int) $_POST['z']);
    if (false === $iPlanetId) {
        exit(json::encode(array(array('msg', 'Planet not found!'))));
    }
    if (!db_insert('mail', array('to_planet_id' => $iPlanetId, 'from_planet_id' => PLANET_ID, 'utc_sent' => time(), 'myt_sent' => $GAMEPREFS['tickcount'], 'message' => $_POST['message']))) {
        exit(json::encode(array(array('msg', 'Mail delivery failed!'))));
    }
    exit(json::encode(array(array('msg', 'Mail sent!'))));
}
_header();
?>
<div class="header">Communication</div>

<br />

Send mail:<br />
<form action="communication.php" method="post" onsubmit="return postForm(this,H);" autocomplete="off">
<table border="0" cellpadding="2" cellspacing="0">
<tr valign="top">
	<td>To:</td>
	<td>
		<input type="text" id="recip_x" name="x" style="width:30;text-align:center;" value="<?php 
echo isset($_GET['x']) ? (int) $_GET['x'] : 'X';
?>
" onfocus="this.select();"> :
		<input type="text" id="recip_y" name="y" style="width:30;text-align:center;" value="<?php 
开发者ID:rudiedirkx,项目名称:Pornstars,代码行数:31,代码来源:communication.php

示例15: max

}
div.set span.card {
	background-color	: gold;
}
</style>
<script type="text/javascript">
<!--//
var ROWS = 8, COOKIENAME = '<?php 
echo S_NAME . '_balance';
?>
', g_iBalance = Cookie.get(COOKIENAME).toInt();
var g_iBetBase = <?php 
echo max(1, min(10, isset($_GET['base']) ? (int) $_GET['base'] : 1));
?>
, g_arrCards = <?php 
echo json::encode($arrCards);
?>
, g_iMultiplier = 1, g_iRow = 0, g_bGateCard = true, g_bGameOver = false;
function nextRow() {
	if ( 0 === g_iRow ) {
		return initTower();
	}
	return fillAndShowRow(++g_iRow);
}
function burnCard(r, c) {
	$('c'+r+''+c).style.backgroundColor = 'black';
	return false;
}
function unburnCard(r, c) {
	$('c'+r+''+c).style.backgroundColor = '';
	return false;
开发者ID:rudiedirkx,项目名称:Games,代码行数:31,代码来源:157.php


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