本文整理匯總了PHP中Viewer::view方法的典型用法代碼示例。如果您正苦於以下問題:PHP Viewer::view方法的具體用法?PHP Viewer::view怎麽用?PHP Viewer::view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Viewer
的用法示例。
在下文中一共展示了Viewer::view方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: set_time_limit
require_once $_SERVER['DOCUMENT_ROOT'] . '/application/modules/viewer.php';
set_time_limit(0);
try {
$addressBook = new AddressBook();
while (true) {
$timestamp = isset($_GET['timestamp']) ? (int) $_GET['timestamp'] : null;
clearstatcache();
if ($timestamp == null || $addressBook->getTimestamp() > $timestamp) {
clearstatcache();
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
if (isset($_GET['act']) && $_GET['act'] == 'ajax') {
header('Content-Type: application/json');
echo json_encode(array('data' => $addressBook->get(), 'timestamp' => $addressBook->getTimestamp()));
} else {
Viewer::view('contacts');
}
break;
case 'PUT':
$data = file_get_contents('php://input');
$addressBook->create(new Contact($data['id'], $data['name'], $data['phone']));
break;
case 'DELETE':
$data = file_get_contents('php://input');
$addressBook->delete(new Contact($data['id'], $data['name'], $data['phone']));
break;
default:
header('HTTP/1.1 405 Unsupported method');
header('Allow: GET, PUT, DELETE');
break;
}