本文整理汇总了PHP中jsonEncode函数的典型用法代码示例。如果您正苦于以下问题:PHP jsonEncode函数的具体用法?PHP jsonEncode怎么用?PHP jsonEncode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jsonEncode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addonlineapplication
function addonlineapplication()
{
$config['upload_path'] = "uploads/onlineapplicants/";
$config['allowed_types'] = "gif|jpg|jpeg|png";
$config['max_size'] = "5000";
$config['max_width'] = "1907";
$config['max_height'] = "1280";
$this->load->library('upload', $config);
//$this->upload->initialize($config);
if (!$this->upload->do_upload('photo')) {
echo $this->upload->display_errors();
} else {
$data = $this->upload->data();
$this->records = array('namebangla' => $this->input->post('namebangla', true), 'nameenglish' => $this->input->post('nameenglish', true), 'fathernamebangla' => $this->input->post('fathernamebangla', true), 'fathernameenglish' => $this->input->post('fathernameenglish', true), 'mothernamebangla' => $this->input->post('mothernamebangla', true), 'mothernameenglish' => $this->input->post('mothernameenglish', true), 'birthdate' => $this->input->post('birthdate', true), 'mobileno' => $this->input->post('mobileno', true), 'permanentaddress' => $this->input->post('permanentaddress', true), 'presentaddress' => $this->input->post('presentaddress', true), 'othersgurdian' => $this->input->post('othersgurdian', true), 'relation' => $this->input->post('relation', true), 'othersgurdianpermanentaddress' => $this->input->post('othersgurdianpermanentaddress', true), 'othersgurdianpresentaddress' => $this->input->post('othersgurdianpresentaddress', true), 'gurdianmobileno' => $this->input->post('gurdianmobileno', true), 'nationality' => $this->input->post('nationality', true), 'gender' => $this->input->post('gender', true), 'religion' => $this->input->post('religion', true), 'stdgroup' => $this->input->post('stdgroup', true), 'class' => $this->input->post('class', true), 'section' => $this->input->post('section', true), 'photo' => $data['file_name'], 'isActive' => 1);
$this->results = $this->common_model->insertRecords($this->common_model->_applicants, $this->records);
if ($this->results) {
//$x = "Test Success";
$this->status['status'] = 1;
$this->status['msg'] = "Applicant";
} else {
//$x = "Test Fail";
$this->status['status'] = 0;
$this->status['msg'] = "Something went wrong when saving the file, please try again.";
}
echo jsonEncode($this->status);
//echo jsonEncode(array('success' => $x));
}
}
开发者ID:skydotint,项目名称:smartcampus,代码行数:28,代码来源:Onlineadmission.php
示例2: Set
public function Set()
{
$path = get('path', 'txt');
$data = get('data');
$data = (strlen($data) <= 5) ? (($data == 'true') ? true : (($data == 'false') ? false : $data)) : $data;
exit(jsonEncode(ini($path, $data)));
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:7,代码来源:ini.mod.php
示例3: jsonEncode
function jsonEncode($obj)
{
switch (true) {
case is_array($obj):
if (is_associative($obj)) {
$arr_out = array();
foreach ($obj as $key => $val) {
$arr_out[] = '"' . $key . '" : ' . jsonEncode($val);
}
return "{\n " . implode(",\n ", $arr_out) . "\n}";
}
$arr_out = array();
$ct = count($obj);
for ($j = 0; $j < $ct; $j++) {
$arr_out[] = jsonEncode($obj[$j]);
}
return '[' . implode(',', $arr_out) . ']';
case is_int($obj):
return $obj;
case is_bool($obj):
return $obj ? 'true' : 'false';
default:
$str_out = stripslashes(trim($obj));
$str_out = str_replace(array('"', '', '/', "\r", "\n"), array('\\"', "\\", '/', '', '\\n'), $str_out);
return '"' . $str_out . '"';
}
}
开发者ID:axoquen,项目名称:tt780,代码行数:27,代码来源:jsonEncode.php
示例4: Ajax
function Ajax()
{
$fid = get('fid', 'txt');
$wd = get('wd', 'txt');
$result = logic('isearcher')->Search($fid, $wd);
exit(jsonEncode($result));
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:7,代码来源:search.mod.php
示例5: getVehicleModelByID
function getVehicleModelByID($id, $session)
{
if (isLogin($session)) {
$jsonObj = new stdClass();
$jsonObj->ID = 1001;
$data['encoded_data'] = jsonEncode($jsonObj);
$this->load->view('json', $data);
}
}
开发者ID:samarulrajt,项目名称:codeigniter-smartgwt,代码行数:9,代码来源:VehicleModel.php
示例6: errorOccurred
function errorOccurred($num, $str, $file, $line)
{
$err = array('yError' => "{$str}. \n File: {$file} \n Line: {$line}");
if (function_exists('jsonEncode')) {
echo jsonEncode($err);
} else {
echo $err['yError'];
}
exit;
}
开发者ID:silky,项目名称:littlesis,代码行数:10,代码来源:yshout.php
示例7: doLogin
public function doLogin()
{
if ($this->username == "admin" && $this->password == "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918") {
$session_id = $this->setSession($this->username);
$jsonReq = array("session" => $session_id, "prkey" => time());
echo jsonEncode($jsonReq);
} else {
echo '{"session":"@@@"}';
}
}
开发者ID:samarulrajt,项目名称:codeigniter-smartgwt,代码行数:10,代码来源:LoginService.php
示例8: Get
public function Get()
{
$path = get('path', 'txt');
list($search, $field) = explode('/', $path);
list($sWhere, $sTable) = explode('@', $search);
list($sField, $sValue) = explode(':', $sWhere);
$sql = 'SELECT `'.$field.'` FROM '.table($sTable).' WHERE '.$sField.'='.(is_numeric($sValue) ? $sValue : '"'.$sValue.'"');
$result = dbc()->Query($sql)->GetRow();
exit(jsonEncode($result[$field]));
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:10,代码来源:dbf.mod.php
示例9: notice
/**
* rmp营销网首页提醒
*/
function notice()
{
$return = array('status' => 0, 'msg' => '');
if ($this->user['userRole'] != 1) {
echo jsonEncode($return);
exit;
}
//查询条件
$where = array('isDel' => 0, 'status' => 1);
//年份
$year = $this->config->item('nowYear');
$year && ($where['year'] = $year);
//时段
//$timeUnit = (int)$this->input->get('timeUnit');
//查询项目数据
$this->load->model('projectModel');
$proList = $this->projectModel->getNewList($where, NULL, NULL, '', 'proId desc');
//查询专营店项目数据
$this->load->model('storeProModel');
$storeProList = $this->storeProModel->getProListKeyProId($this->user['userId']);
//筛选出各审核状态的数据
$list1 = array();
$list2 = array();
$list3 = array();
foreach ($proList as $v) {
$v['proId'] = (int) $v['proId'];
if (isset($storeProList[$v['proId']])) {
$storeProData = $storeProList[$v['proId']];
if ($storeProData['auditRs'] == -1) {
//未提交
$list1[] = $v;
} else {
if ($storeProData['auditRs'] == 0) {
//待审核
$v['storeData'] = $storeProData;
$list2[] = $v;
} else {
//已审核
$v['storeData'] = $storeProData;
$list3[] = $v;
}
}
} else {
$list1[] = $v;
}
}
if ($list1) {
$return['status'] = 1;
$return['msg'] = 'RMP端执行反馈系统有新的反馈内容需要填写';
echo jsonEncode($return);
exit;
}
echo jsonEncode($return);
exit;
}
开发者ID:zhaojianhui129,项目名称:implement2016,代码行数:58,代码来源:Main.php
示例10: loadReportList
/**
* 载入报表类型json数据
*/
function loadReportList()
{
$fundType = (int) $this->input->post('fundType');
require_once APPPATH . 'libraries/JSON.php';
$list = array();
$list[] = array('key' => '', 'value' => '请选择');
if (isset($this->reportList[$fundType])) {
foreach ($this->reportList[$fundType] as $k => $v) {
$list[] = array('key' => $k, 'value' => $v);
}
}
echo jsonEncode($list);
exit;
}
开发者ID:zhaojianhui129,项目名称:qirmp2016,代码行数:17,代码来源:Report.php
示例11: editprofileajax
public function editprofileajax()
{
$this->id = $this->input->post('id', true);
$this->where = array('id' => $this->id);
$this->records = array('password' => $this->input->post('password', true));
$this->results = $this->common_model->updateRecords($this->common_model->_usersTable, $this->records, $this->where);
if ($this->results == 1) {
$this->status['status'] = 1;
$this->status['msg'] = "Password";
} else {
$this->status['status'] = 0;
$this->status['msg'] = "Something went wrong when saving the file, please try again.";
}
echo jsonEncode($this->status);
}
开发者ID:skydotint,项目名称:smartcampus,代码行数:15,代码来源:Profiles.php
示例12: Get
public function Get()
{
$path = get('path', 'txt');
list($search, $lgName) = explode('@', $path);
list($sParm, $lgFunc) = explode('~', $search);
$logic = logic($lgName);
if (method_exists($logic, $lgFunc))
{
$r = $logic->$lgFunc('get', $sParm);
}
else
{
$r = false;
}
exit(jsonEncode($r));
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:16,代码来源:lgc.mod.php
示例13: Main
function Main()
{
$class = get('class')=='mail'?'mail':'sms';
$runx = 13;
$pause = 60;
$MT = ini('service.push.mthread');
if ($MT || $class == 'sms')
{
$runx = 30;
$pause = 10;
}
logic('push')->run($runx, $class);
echo jsonEncode(array(
'extend' => ($class=='sms'?'mail':'sms'),
'interval' => $pause
));
$this->extend();
exit;
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:20,代码来源:pingfore.mod.php
示例14: jsonEncode
function jsonEncode($var)
{
if (function_exists('json_encode')) {
return json_encode($var);
} else {
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
// Lowercase necessary!
// Lowercase necessary!
case 'integer':
case 'double':
return $var;
case 'resource':
case 'string':
return '"' . str_replace(array("\r", "\n", "<", ">", "&"), array('\\r', '\\n', '\\x3c', '\\x3e', '\\x26'), addslashes($var)) . '"';
case 'array':
// Arrays in JSON can't be associative. If the array is empty or if it
// has sequential whole number keys starting with 0, it's not associative
// so we can go ahead and convert it as an array.
if (empty($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
$output = array();
foreach ($var as $v) {
$output[] = jsonEncode($v);
}
return '[ ' . implode(', ', $output) . ' ]';
}
// Otherwise, fall through to convert the array as an object.
// Otherwise, fall through to convert the array as an object.
case 'object':
$output = array();
foreach ($var as $k => $v) {
$output[] = jsonEncode(strval($k)) . ': ' . jsonEncode($v);
}
return '{ ' . implode(', ', $output) . ' }';
default:
return 'null';
}
}
}
开发者ID:shofe,项目名称:study,代码行数:40,代码来源:jk_helper.php
示例15: contactajax
function contactajax()
{
error_reporting(0);
$data['settings'] = $this->settings_model->getSettings();
$ad = $data['settings'][0];
$instituteemail = $ad['instituteemail'];
$fullname = $this->input->post('fullname', true);
$mobileno = $this->input->post('mobileno', true);
$email = $this->input->post('email', true);
$subject = $this->input->post('subject', true);
$message = $this->input->post('message', true);
$msg = "Name:" . $fullname . "\n" . "Contact Number:" . $mobileno . "\n" . "Message:" . $message;
//$receiverEmail = "[email protected]";
//$to = "[email protected]";
$to = $instituteemail;
//$subject = "Test mail";
if ($subject) {
$subject = $subject;
} else {
$subject = "Contact Form";
}
//$message = "Hello! This is a simple email message.";
$message = $msg;
//$from = "[email protected]";
$from = $email;
$headers = "From:" . $from;
$send = @mail($to, $subject, $message, $headers);
if ($send) {
$this->status['status'] = 1;
$this->status['msg'] = "আমাদের সাথে যোগাযোগ করার জন্য আপনাকে ধন্যবাদ";
} else {
$this->status['status'] = 0;
$this->status['msg'] = "Something went wrong sending contact information.";
}
echo jsonEncode($this->status);
}
开发者ID:skydotint,项目名称:smartcampus,代码行数:36,代码来源:Contact.php
示例16: K
KindEditor.ready(function(K) {
var uploadbutton_<?php
echo $itemId;
?>
= K.uploadbutton({
button : K('#imgUpload<?php
echo $itemId;
?>
')[0],
fieldName : 'imgFile',
url : '<?php
echo $uploadUrl;
?>
',
extraParams:<?php
echo $extraParams ? jsonEncode($extraParams) : jsonEncode(array());
?>
,
afterUpload : function(data) {
layer.closeAll('loading'); //关闭加载层
if (data.error === 0) {
if ($("#imgUpload<?php
echo $itemId;
?>
Download").length > 0) {
var url = K.formatUrl(data.url, 'absolute');
var html = '<a role="button" aria-label="Left Align" href="index.php?c=Upload&m=download&fileId='+data.fileId+'" class="btn btn-default" type="button"><span aria-hidden="true" class="glyphicon glyphicon-download-alt"></span>附件下载</a>';
$("#imgUpload<?php
echo $itemId;
?>
Download").html(html);
开发者ID:zhaojianhui129,项目名称:implement2016,代码行数:31,代码来源:actItem7.php
示例17: Iframe
function Iframe()
{
$field = get('field', 'txt');
$result = logic('upload')->Save($field, false, false);
if (isset($result['error']) && $result['error'])
{
$ops = array(
'status' => 'fails',
'msg' => $result['msg']
);
}
else
{
$ops = array(
'status' => 'ok',
'file' => $result
);
}
exit('<script type="text/javascript">window.parent.ups_Result('.jsonEncode($ops).');</script>');
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:20,代码来源:upload.mod.php
示例18: json_decode
// ***********************
// SALLES
// ***********************
// !!!! Pas encore à jour avec la nouvelle version d'ADE !!!!
$json = json_decode(file_get_contents("../dictionaries/rooms.json"), TRUE);
$listeRooms = $json["rooms"];
foreach ($listeRooms as $ics) {
$json = icsToArray("../../cache/ics/{$ics['nom']}.ics");
$calendrier = array();
if (isset($json)) {
foreach ($json as $event) {
if ($event["BEGIN"] == "VEVENT") {
$dateEvent = date("z", strtotime($event["DTSTART"]));
if ($dateEvent >= $aujourdhui && $dateEvent < $aujourdhui + 4) {
$enCours = array();
$enCours["DEBUT"] = strtotime($event["DTSTART"]);
$enCours["FIN"] = strtotime($event["DTEND"]);
$enCours["JOUR"] = date("z", strtotime($event["DTSTART"]));
$enCours["NOM"] = ucfirst($event["SUMMARY"]);
$enCours["SECTION"] = preg_replace("#Etudiant : ([A-Z0-9]+) .+#", '$1', $event["DESCRIPTION"]);
if (preg_match("#nEnseignants #", $enCours["SECTION"])) {
$enCours["SECTION"] = "";
}
$calendrier[] = $enCours;
}
}
}
usort($calendrier, "triDate");
file_put_contents("../../cache/json/{$ics['nom']}.json", jsonEncode($calendrier));
}
}
开发者ID:KenAlin,项目名称:EDT-Polytech-Montpellier,代码行数:31,代码来源:icsToJson.php
示例19: editFun
資料</span></h1>
<div class="pidding_5">
<table cellspacing="0" cellpadding="0" class="Admin_L">
<tr>
<th class="T_title" scope="col" width="150"><?php
echo $classStr;
?>
資料</th>
<th class="T_title" scope="col" colspan="7"> </th>
</tr>
<?php
include $_GET['type'] . '/' . $className . '.form.php';
?>
<tr class="Ls2">
<td class="N_title"> </td>
<td class="N_title" colspan="7"><input class="sub2" type="submit" value="送出表單"></td>
</tr>
</table>
</div>
</form>
<?php
if ($info) {
?>
<script>
editFun(<?php
echo jsonEncode($info);
?>
);
</script>
<?php
}
开发者ID:austinliniware,项目名称:tsci-rota,代码行数:31,代码来源:info.php
示例20: prune
function prune($ids = false, $user_id = false)
{
if (is_array($ids)) {
$sql = 'SELECT us_id AS US_ID, us_elements AS US_ELEMENTS ' . 'FROM user_slideshows ' . 'WHERE us_u_id = ' . intval($user_id) . ' ';
$data = $this->dbh->query_all($sql);
//loop through each slideshow
foreach ($data as $k => $v) {
$update = false;
$elements = jsonDecode($v['US_ELEMENTS']);
// loop through the elements array
// if $v['photoId_int'] is in the ids array
// then unset that element
if (is_array($elements)) {
foreach ($elements as $k_element => $v_element) {
if (in_array($v_element['photoId_int'], $ids)) {
// delete this element from the data array
unset($elements[$k_element]);
$update = true;
}
}
}
if ($update === true) {
//rewrite this slideshow
$elements = jsonEncode($elements);
$sql = 'UPDATE user_slideshows ' . 'SET us_elements = ' . $this->dbh->sql_safe($elements) . ' ' . 'WHERE us_id = ' . intval($v['US_ID']) . ' ';
$this->dbh->execute($sql);
}
}
} else {
$sql = 'SELECT us_elements AS US_ELEMENTS ' . 'FROM user_slideshows ' . 'WHERE us_d_id = ' . intval($user_id) . ' ';
$data = $this->dbh->query_all($sql);
//loop through each slideshow
foreach ($data as $k => $v) {
$update = false;
$elements = jsonDecode($v['US_ELEMENTS']);
// loop through the elements array
// if $v['photoId_int'] is in the ids array
// then unset that element
if (is_array($elements)) {
foreach ($elements as $k_element => $v_element) {
if ($v_element['photoId_int'] == $id) {
unset($elements[$k_element]);
$update = true;
}
}
}
if ($update === true) {
//rewrite this slideshow
$elements = jsonEncode($elements);
$sql = 'UPDATE user_slideshows ' . 'SET us_elements = ' . $this->dbh->sql_safe($elements) . ' ' . 'WHERE us_id = ' . intval($v['US_ID']) . ' ';
$this->dbh->execute($sql);
}
}
}
}
开发者ID:jmathai,项目名称:photos,代码行数:55,代码来源:CFlixManage.php
注:本文中的jsonEncode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论