本文整理匯總了PHP中jsonEncode函數的典型用法代碼示例。如果您正苦於以下問題:PHP jsonEncode函數的具體用法?PHP jsonEncode怎麽用?PHP jsonEncode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了jsonEncode函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
}
示例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)));
}
示例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 . '"';
}
}
示例4: Ajax
function Ajax()
{
$fid = get('fid', 'txt');
$wd = get('wd', 'txt');
$result = logic('isearcher')->Search($fid, $wd);
exit(jsonEncode($result));
}
示例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);
}
}
示例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;
}
示例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":"@@@"}';
}
}
示例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]));
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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';
}
}
}
示例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 = "dev.saddam@gmail.com";
//$to = "dev.saddam@gmail.com";
$to = $instituteemail;
//$subject = "Test mail";
if ($subject) {
$subject = $subject;
} else {
$subject = "Contact Form";
}
//$message = "Hello! This is a simple email message.";
$message = $msg;
//$from = "dev.saddam25@gmail.com";
$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);
}