:::

11. api.php

<?php
require_once "NewsRest.php";
$NewsRest = new NewsRest();

// 過濾外來變數
$op      = isset($_REQUEST['op']) ? filter_var($_REQUEST['op'], FILTER_SANITIZE_STRING) : 'index';
$p       = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 1;
$id      = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$cate_id = isset($_REQUEST['cate_id']) ? (int) $_REQUEST['cate_id'] : 0;
$keyword = isset($_REQUEST['keyword']) ? filter_var($_REQUEST['keyword'], FILTER_SANITIZE_STRING) : '';
$year    = isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : 0;

switch ($op) {
    case 'index':
        echo $NewsRest->index($p, $cate_id, $keyword, $year);
        break;

    case 'show':
        echo $NewsRest->show($id);
        break;

    case 'count':
        echo $NewsRest->count();
        break;
}

 


:::

書籍目錄

展開 | 闔起

http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D53%26tbdsn%3D1878

計數器

今天: 539539539
昨天: 2455245524552455
總計: 6115236611523661152366115236611523661152366115236