本文整理匯總了PHP中response::to_json方法的典型用法代碼示例。如果您正苦於以下問題:PHP response::to_json方法的具體用法?PHP response::to_json怎麽用?PHP response::to_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類response
的用法示例。
在下文中一共展示了response::to_json方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fields
function fields()
{
$res = new response();
$db = $this->params["db"];
$table = $this->params["table"];
//query
$result = Doo::db()->fetchAll("SHOW COLUMNS IN {$table} IN {$db}");
foreach ($result as $row) {
$data[] = array('field' => $row["Field"], 'type' => $row["Type"], 'null' => $row['Null'], 'key' => $row['Key'], 'default' => $row['Default']);
}
$res->data = $data;
$res->success = true;
echo $res->to_json();
}
示例2: send
/**
* @access public
* @param string $content The content
* @param string $type The content type
* @param boolean $no_cache Disable caching, default TRUE
*/
public static function send($content, $type, $no_cache = true)
{
if (headers_sent()) {
die($content);
//9* 16072010 USABLE WITH dbg:show(). If headers already sent do nothing with them.
}
switch (strtolower($type)) {
case 'html':
header('Content-Type: text/html; charset=' . ENCODING);
break;
case 'xml':
header('Content-Type: text/xml; charset=' . ENCODING);
break;
case 'javascript':
case 'js':
header('Content-Type: text/javascript; charset=' . ENCODING);
break;
case 'json':
header('Content-Type: text/x-json; charset=UTF-8');
if (is_array($content)) {
$content = response::to_json($content);
}
break;
case 'error':
$data = array('success' => false, 'errors' => $content);
header('Content-Type: text/x-json; charset=UTF-8');
$content = response::to_json($data);
break;
case 'noheaders':
$no_cache = false;
break;
case 'text':
case 'txt':
default:
header('Content-Type: text/plain; charset=' . ENCODING);
break;
}
if ($no_cache) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// disable IE caching
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}
die($content);
}
示例3: response
function gearman_status()
{
$res = new response();
require_once 'Net/Gearman/Manager.php';
$id = $this->params["id"];
$server = Doo::db()->getOne('GearmanJobServers', array('where' => "id = {$id}"));
if ($server == false) {
$res->message = "invalid id";
$res->success = false;
} else {
try {
$manager = new Net_Gearman_Manager($server->hostname . ":" . $server->port);
$res->data = $manager->status();
$res->success = true;
} catch (Net_Gearman_Exception $e) {
$res->message = $e->getMessage();
$res->success = false;
}
}
echo $res->to_json();
}
示例4: sys_set
/**
* Добавить \ Сохранить файл
*/
protected function sys_set()
{
$fid = $this->args['_sid'];
if ($fid > 0) {
$file = $this->get_file($fid);
$old_file_name = $file->real_name;
}
$file = !empty($old_file_name) ? file_system::replace_file('file', $old_file_name) : file_system::upload_file('file');
if ($file !== false) {
if (!($fid > 0)) {
$file['created_date'] = date('Y-m-d : H:i:s');
}
$file['changed_date'] = date('Y-m-d : H:i:s');
$this->set_args($file, true);
$this->_flush();
$this->insert_on_empty = true;
$result = $this->extjs_set_json(false);
} else {
$result = array('success' => false);
}
response::send(response::to_json($result), 'html');
}