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