本文整理匯總了PHP中Library::getBooks方法的典型用法代碼示例。如果您正苦於以下問題:PHP Library::getBooks方法的具體用法?PHP Library::getBooks怎麽用?PHP Library::getBooks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Library
的用法示例。
在下文中一共展示了Library::getBooks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Library
<?php
include "library.php";
$lib = new Library();
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case "getBooks":
$data = $lib->getBooks();
break;
case "greetStudent":
$data = $lib->greetStudent(filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING));
break;
default:
// PHP 5.4+ only, use code below for earlier versions
http_response_code(400);
// PHP < 5.4 use the line below instead
// header("Status: 400", false, 400);
$data = array("error" => "bad request");
}
header("Content-Type: application/json");
echo json_encode($data);
}
示例2: getBooksJson
/**
* http://localhost/debug/books-json
*
* @return String
*/
public function getBooksJson()
{
# Old school way of getting books using the Library class and books.json
# We've since updated this method with the Book model class and `books` table
# Instantiating an object of the Library class
$library = new Library(app_path() . '/database/books.json');
# Get the books
$books = $library->getBooks();
# Debug
return Pre::render($books, 'Books');
}