本文整理汇总了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;
}