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


PHP JSON_encode函数代码示例

本文整理汇总了PHP中JSON_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP JSON_encode函数的具体用法?PHP JSON_encode怎么用?PHP JSON_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: go_mark_read

function go_mark_read()
{
    global $wpdb;
    $messages = get_user_meta(get_current_user_id(), 'go_admin_messages', true);
    if ($_POST['type'] == 'unseen') {
        if ($messages[1][$_POST['date']][1] == 1) {
            $messages[1][$_POST['date']][1] = 0;
            (int) ($messages[0] = (int) $messages[0] - 1);
        }
    } elseif ($_POST['type'] == 'remove') {
        if ($messages[1][$_POST['date']][1] == 1) {
            (int) ($messages[0] = (int) $messages[0] - 1);
        }
        unset($messages[1][$_POST['date']]);
    } else {
        if ($_POST['type'] == 'seen') {
            if ($messages[1][$_POST['date']][1] == 0) {
                $messages[1][$_POST['date']][1] = 1;
                (int) ($messages[0] = (int) $messages[0] + 1);
            }
        }
    }
    update_user_meta(get_current_user_id(), 'go_admin_messages', $messages);
    echo JSON_encode(array(0 => $_POST['date'], 1 => $_POST['type'], 2 => $messages[0]));
    die;
}
开发者ID:SpencerNussbaum,项目名称:game-on,代码行数:26,代码来源:go_messages.php

示例2: loging

 public function loging()
 {
     //var_dump($this->input->post());
     $sql = "SELECT * FROM user ";
     $sql .= " WHERE ";
     $sql .= " userid='" . $this->input->post('email') . "'";
     $sql .= " and password='" . $this->input->post('password') . "'";
     //echo $sql;
     $query = $this->db->query($sql);
     //echo "Numrows=".$query->num_rows();
     if ($query->num_rows() > 0) {
         // get existing array from session var (returns false if first time called)
         $row = $query->row();
         //$userid = $row('email');
         //$username = $row('name');
         $this->session->set_userdata('userlogin', $row);
         //$var = $this->session->userdata;
         //echo $var['username'];
         //****************************************
         //$userlogin = $row;
         // add new $key=>$val to array
         //$userlogin['userid'] = $this->input->post('email');
         //$userlogin['username'] = $this->input->post('name');
         // pass it back to the session var
         //$this->session->set_userdata('userlogin',$userlogin);
         echo JSON_encode($row);
         //echo "Login completed ...";
         //$this->output->set_header('refresh:5;url=../eportfolio/home');
         // echo JSON_encode($userlogin);
     } else {
         //echo "Login error";
         //$this->output->set_header('refresh:5;url=../user/loginform');
         echo '{"result":true,"count":1}';
     }
 }
开发者ID:anucha1977,项目名称:ePortfolio,代码行数:35,代码来源:user.php

示例3: smarty_function_json_encode

/**
 * Smarty {json_encode} function plugin
 *
 * Type:     function<br>
 * Name:     json_encode<br>
 * Purpose:  encode given object to JSON format
 * Input:<br>
 *         - obj = object to encode (required)
 * @author   Karel Kozlik <kozlik@kufr.cz>
 * @version  1.0
 * @param array parameters
 * @param Smarty
 * @return string|null
 */
function smarty_function_json_encode($params, &$smarty)
{
    if (!in_array('obj', array_keys($params))) {
        $smarty->trigger_error("array_count: missing 'obj' parameter");
        return;
    }
    return JSON_encode($params['obj']);
}
开发者ID:BackupTheBerlios,项目名称:serweb-frmwrk,代码行数:22,代码来源:function.json_encode.php

示例4: TH_customername_autocomplete

 public function TH_customername_autocomplete()
 {
     $USERSTAMP=$this->Mdl_eilib_common_function->getSessionUserStamp();
     $errorlist= $this->input->post('ErrorList');
     $ErrorMessage= $this->Mdl_eilib_common_function->getErrorMessageList($errorlist);
     $result = $this->Mdl_report_tickler_history->customername_autocomplete($USERSTAMP,$ErrorMessage) ;
     echo JSON_encode($result);
 }
开发者ID:Rajagunasekaran,项目名称:BACKUP,代码行数:8,代码来源:Ctrl_Report_Tickler_History.php

示例5: bxtviz_add_chart

function bxtviz_add_chart()
{
    global $bxttoptions;
    global $wpdb;
    $options = $bxttoptions;
    $charts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "bxtvisualization");
    echo JSON_encode($charts);
    exit;
}
开发者ID:benznext,项目名称:bxt-visualization,代码行数:9,代码来源:process-ajax.php

示例6: action

 private function action()
 {
     if ($db = new SQLiteDatabase(_MINDSRC_ . '/mind3rd/SQLite/mind')) {
         $result = $db->query("SELECT * FROM user where login='" . $this->login . "' AND pwd='" . sha1($this->pwd) . "' AND status= 'A'");
         $row = false;
         while ($result->valid()) {
             $row = $result->current();
             $_SESSION['auth'] = JSON_encode($row);
             $_SESSION['login'] = $row['login'];
             break;
         }
         if (!$row) {
             Mind::write('auth_fail', true);
             return false;
         }
     } else {
         die('Database not found!');
     }
     return $this;
 }
开发者ID:jaydson,项目名称:theWebMind,代码行数:20,代码来源:Auth.php

示例7: go_clipboard_get_data

function go_clipboard_get_data()
{
    global $wpdb;
    //grabs the selection
    // 0 = bonus currency
    // 1 = points
    // 2 = completed
    // 3 = mastered
    // 4 = currency
    // 5 = penalty
    $selection = $_POST['go_graph_selection'];
    if (isset($_POST['go_class_a'])) {
        $class_a_choice = $_POST['go_class_a'];
    } else {
        $class_a_choice = array();
    }
    if (isset($_POST['go_choices_checked_names'])) {
        $go_choices_checked_names = $_POST['go_choices_checked_names'];
    } else {
        $go_choices_checked_names = array();
    }
    $array = get_option('go_graphing_data', false);
    $users_in_class = array();
    foreach ($class_a_choice as $value) {
        if (!array_key_exists($value, $users_in_class)) {
            $users_in_class[$value] = array();
        }
    }
    $table_name_go_totals = $wpdb->prefix . 'go_totals';
    $uids = $wpdb->get_results("SELECT uid FROM " . $table_name_go_totals . "");
    // loops through game on users and places each user in their respective class_a
    foreach ($uids as $uid) {
        foreach ($uid as $id) {
            $user_class = get_user_meta($id, 'go_classifications', true);
            if ($user_class) {
                $class = array_keys($user_class);
                $check = array_intersect($class, array_keys($users_in_class));
                if ($check) {
                    if (count($check) > 1 || count($class) > 1) {
                        foreach ($check as $value) {
                            $users_in_class[$value][] = $id;
                        }
                    } else {
                        $key = (string) $check[0];
                        $users_in_class[$key][] = $id;
                    }
                }
            }
        }
    }
    // loops through users in each class and creates array of all their data
    foreach ($users_in_class as $class => $students) {
        // date is the unix timestamp of the last time data was collected using the go_clipboard_collect_data function
        foreach ($array as $id => $date) {
            if (in_array($id, $students)) {
                $getinfo = get_userdata($id);
                $id = $getinfo->user_login;
                $first = $getinfo->first_name;
                $last = $getinfo->last_name;
                $info[$id]['label'] = $last . ', ' . $first . ' (' . $id . ')';
                $info[$id]['class_a'][] = $class;
                foreach ($date as $date => $content) {
                    // Bonus Currency, penalty, points, completed, and mastered array associated with the unix timestamp when go_clipboard_collect_data function ran
                    $content_array = explode(',', $content);
                    // generates array of user data associated with a unix timestamp, then appends the unix timestamp$content_array's element which corresponds to the graph selection key above
                    $info[$id]['data'][] = array($date * 1000, $content_array[$selection]);
                }
            }
        }
    }
    if ($go_choices_checked_names) {
        $info['checked'] = $go_choices_checked_names;
    }
    // stringifies the php array into a json object
    echo JSON_encode($info);
    die;
}
开发者ID:zetheroth,项目名称:game-on,代码行数:77,代码来源:go_clipboard.php

示例8: saveState

 /**
  * $this->state tárolása session -ba
  */
 protected function saveState()
 {
     $session = JFactory::getSession();
     $session->set($this->browserName . 'State', JSON_encode($this->state));
 }
开发者ID:utopszkij,项目名称:lmp,代码行数:8,代码来源:components.php

示例9: browse

 /**
  * browse task
  * @return void
  * @request integer limit
  * @request integer limitstart
  * @request integer order
  * @request integer filterStr
  * @request integer temakor
  * @request integer szavazas      
  * @session object 'temakoroklist_status'   
  */
 public function browse()
 {
     jimport('hs.user.user');
     JHTML::_('behavior.modal');
     $total = 0;
     $pagination = null;
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     // alapértelmezett browser status beolvasása sessionból
     $session = JFactory::getSession();
     $brStatusStr = $session->get($this->NAME . 'list_status');
     if ($brStatusStr == '') {
         $brStatusStr = '{"limit":20,"limitstart":0,"order":1,"filterStr":"","temakor_id":0,"szavazas_id":0}';
     }
     $brStatus = JSON_decode($brStatus);
     $limitStart = JRequest::getVar('limitstart', $brStatus->limitstart);
     $limit = JRequest::getVar('limit', $brStatus->limit);
     $order = JRequest::getVar('order', $brStatus->order);
     $filterStr = urldecode(JRequest::getVar('filterStr', $brStatus->filterStr));
     if ($this->temakor_id == '') {
         $this->temakor_id = $brStatus->temakor_id;
     }
     if ($this->szavazas_id == '') {
         $this->szavazas_id = $brStatus->szavazas_id;
     }
     // browser status save to session and JRequest
     $brStatus->limit = $limit;
     $brStatus->limitStart = $limitStart;
     $brStatus->order = $order;
     $brStatus->filterStr = $filterStr;
     $brStatus->temakor_id = $this->temakor_id;
     $brStatus->szavazas_id = $this->szavazas_id;
     $session->set($this->NAME . 'list_status', JSON_encode($brStatus));
     JRequest::setVar('limit', $limit);
     JRequest::setVar('limitstart', $limitstart);
     JRequest::setVar('order', $order);
     JRequest::setVar('filterStr', $filterStr);
     JRequest::setVar('temakor', $this->temakor_id);
     JRequest::setVar('szavazas', $this->szavazas_id);
     // adattábla tartalom elérése és átadása a view -nek
     $items = $this->model->getItems();
     //DBG echo $this->model->getDBO()->getQuery();
     if ($this->model->getError() != '') {
         $this->view->Msg = $this->model->getError();
     }
     $this->view->set('Items', $items);
     $this->view->set('Temakor', $this->temakor);
     $this->view->set('Szavazas', $this->szavazas);
     $this->view->set('Title', JText::_('ALTERNATIVAK'));
     // browser müködéshez linkek definiálása
     if ($this->szavazas->vita1 == 1) {
         $itemLink = JURI::base() . 'index.php?option=com_alternativak&view=alternativak' . '&task=edit' . '&limit=' . JRequest::getVar('limit', '20') . '&limitstart=0' . '&filterStr=' . urlencode($filterStr) . '&order=' . JRequest::getVar('order', '1') . '&temakor=' . $this->temakor_id . '&szavazas=' . $this->szavazas_id;
     } else {
         $itemLink = '';
     }
     $backLink = JURI::base() . 'index.php?option=com_szavazasok&view=szavazasoklist' . '&temakor=' . $this->temakor_id . '&task=browse';
     $homeLink = JURI::base() . 'index.php?option=com_temakorok&view=temakoroklist' . '&task=browse';
     $this->view->set('itemLink', $itemLink);
     $this->view->set('backLink', $backLink);
     $this->view->set('homeLink', $homeLink);
     // van ált. képviselője?
     $altKepviseloje = 0;
     $db->setQuery('select k.kepviselo_id, u.name 
 from #__kepviselok k, #__users u
 where k.kepviselo_id = u.id and
         k.user_id = "' . $user->id . '" and k.temakor_id=0 and k.szavazas_id = 0 and
         k.lejarat >= "' . date('Y-m-d') . '"');
     $res = $db->loadObject();
     if ($db->getErrorNum() > 0) {
         $db->stderr();
     }
     if ($res) {
         $altKepviseloje = $res->kepviselo_id;
     }
     // van témakör képviselője?
     $kepviseloje = 0;
     $db->setQuery('select k.kepviselo_id, u.name 
 from #__kepviselok k, #__users u
 where k.kepviselo_id = u.id and
         k.user_id = "' . $user->id . '" and k.temakor_id=' . $this->temakor_id . ' and k.szavazas_id = 0 and
         k.lejarat >= "' . date('Y-m-d') . '"');
     $res = $db->loadObject();
     if ($db->getErrorNum() > 0) {
         $db->stderr();
     }
     if ($res) {
         $kepviseloje = $res->kepviselo_id;
     }
     // Ő maga képviselő jelölt?
//.........这里部分代码省略.........
开发者ID:madcsaba,项目名称:li-de,代码行数:101,代码来源:controller.php

示例10: bdyupdatefunction

 public function bdyupdatefunction()
 {
     $USERSTAMP=$this->Mdl_eilib_common_function->getSessionUserStamp();
     $result = $this->Mdl_email_template_entry_search_update->update_bdydata($USERSTAMP,$this->input->post('id'),$this->input->post('bodyvalue')) ;
     echo JSON_encode($result);
 }
开发者ID:Rajagunasekaran,项目名称:BACKUP,代码行数:6,代码来源:Ctrl_Email_Template_Entry_Search_Update.php

示例11: foreach

<?php

include 'db_connect.php';
if ($_POST['param'] == "getNames") {
    $stmt = $db->prepare('SELECT * FROM queriesJSON WHERE username = :username ORDER BY simName');
    $stmt->execute(array(':username' => $_POST['username']));
    foreach ($stmt as $row) {
        $data['simName'][] = $row['simName'];
        $data['qid'][] = $row['qid'];
    }
    echo JSON_encode($data);
}
if ($_POST['param'] == "saveSim") {
    $stmt = $db->prepare('INSERT INTO queriesJSON (username, simName, json) VALUES (:username, :simName, :json)');
    $stmt->execute(array(':username' => $_POST['username'], ':simName' => $_POST['simName'], ':json' => $_POST['json']));
    echo JSON_encode('Success');
}
if ($_POST['param'] == "getSavedSim") {
    $stmt = $db->prepare('SELECT * FROM queriesJSON WHERE qid = :qid');
    $stmt->execute(array(':qid' => $_POST['qid']));
    foreach ($stmt as $row) {
        $data['data'] = $row['json'];
        $data['simName'] = $row['simName'];
    }
    echo JSON_encode($data);
}
开发者ID:eyeofthefrog,项目名称:cFIREsim-open,代码行数:26,代码来源:getData.php

示例12: respond

/**
 * Status Codes:
 *      0: Success. No issues.
 *      1: Student already has an order.
 *
 */
function respond($statusCode, $orderId = -1)
{
    echo JSON_encode(array("status" => $statusCode, "orderId" => $orderId));
    exit;
}
开发者ID:DV8FromTheWorld,项目名称:Pizza-Order-Website,代码行数:11,代码来源:submit.php

示例13: session_start

            $msg = "Invalid username or password. Try again.";
            $status = FALSE;
        }
    } else {
        $msg = "Missing password. ";
        $status = FALSE;
    }
} else {
    $msg = "Missing username. ";
    $status = FALSE;
}
// If we got through all that without errors, start a session.
if ($status == TRUE) {
    // Start a session. session_start() and not sessionInit() because this
    // is a file users should not access directly.
    session_start();
    // Get the user's record and pull out the ID, add to the session.
    // (getUser() is in functions.php)
    $inUserRec = getUser($inName, $db);
    $_SESSION['uid'] = $inUserRec['id'];
    // Add the user's name to the session, flag that (s)he's logged in.
    $_SESSION['uname'] = $inName;
    $_SESSION['loggedin'] = TRUE;
    // Redirect to index.php in JavaScript, not here.
}
// Build the JSON response.
$response = array('status' => $status, 'message' => $msg);
// Send the JSON response. (NOTE: This Ajax messaging should be replaced
// with a plain old PHP message in the session. A task for refactoring?
echo JSON_encode($response);
开发者ID:ratclier,项目名称:cs361_projectb,代码行数:30,代码来源:auth.php

示例14: define

<?php

// Configuration values
define('DATA_PATH', 'ppcmarket.txt');
// Get market data from file
function market_info()
{
    $info = json_decode(file_get_contents(DATA_PATH));
    return $info;
}
// Return a JSON array of price / market cap / total supply
echo JSON_encode(market_info());
开发者ID:blackchat,项目名称:peercoin.net,代码行数:12,代码来源:tickerinfo.php

示例15: babypersonalsave

 public function babypersonalsave()
 {
     $USERSTAMP= $this->Mdl_eilib_common_function->getSessionUserStamp();
     $result = $this->Mdl_personal_daily_entry_search_update_delete->babypersonalinsert($USERSTAMP) ;
     echo JSON_encode($result);
 }
开发者ID:Rajagunasekaran,项目名称:BACKUP,代码行数:6,代码来源:Ctrl_Personal_Daily_Entry_Search_Update_Delete.php


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