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


PHP jsonEncode函数代码示例

本文整理汇总了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));
     }
 }
开发者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 = "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);
 }
开发者ID:skydotint,项目名称:smartcampus,代码行数:36,代码来源:Contact.php


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