控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Article;
class ArticleController extends Controller{
public function index()
{
$articles=Article::paginate(2);
//dd($articles);
//dump($articles);
return view('article',compact('articles'));
}
}
视图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
@foreach ($articles as $article)
$article->title <br>
$article->intro <br>
@endforeach</div>
{!! $articles->render() !!}</body>
</html>
路由
Route::get('article','ArticleController@index');
laravel.log
[2016-07-31 01:57:54] local.ERROR: exception 'ErrorException' with message 'htmlspecialchars(): charset `GBK' not supported, assuming utf-8' in D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php:412
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'htmlspecialchar...', 'D:\\laravels\\pro...', 412, Array)
#1 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(412): htmlspecialchars('htmlspecialchar...', 11, 'GBK')
#2 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(248): Symfony\Component\Debug\ExceptionHandler->escapeHtml('htmlspecialchar...')
#3 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(174): Symfony\Component\Debug\ExceptionHandler->getContent(Object(Symfony\Component\Debug\Exception\FlattenException))
#4 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(115): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(ErrorException))
#5 D:\laravels\project\app\Exceptions\Handler.php(48): Illuminate\Foundation\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#6 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(80): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#7 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(34): Illuminate\Routing\Pipeline->handleException(Object(Illuminate\Http\Request), Object(ErrorException))
#8 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#9 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#10 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#12 D:\laravels\project\public\index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#13 {main}
[2016-07-31 01:57:54] local.ERROR: exception 'ErrorException' with message 'htmlspecialchars(): charset `GBK' not supported, assuming utf-8' in D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php:412
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'htmlspecialchar...', 'D:\\laravels\\pro...', 412, Array)
#1 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(412): htmlspecialchars('htmlspecialchar...', 11, 'GBK')
#2 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(248): Symfony\Component\Debug\ExceptionHandler->escapeHtml('htmlspecialchar...')
#3 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(174): Symfony\Component\Debug\ExceptionHandler->getContent(Object(Symfony\Component\Debug\Exception\FlattenException))
#4 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(115): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(ErrorException))
#5 D:\laravels\project\app\Exceptions\Handler.php(48): Illuminate\Foundation\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#6 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(291): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#7 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(103): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(ErrorException))
#8 D:\laravels\project\public\index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#9 {main}
[2016-07-31 01:57:54] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Uncaught exception 'ErrorException' with message 'htmlspecialchars(): charset `GBK' not supported, assuming utf-8' in D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php:412
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'htmlspecialchar...', 'D:\\laravels\\pro...', 412, Array)
#1 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(412): htmlspecialchars('htmlspecialchar...', 11, 'GBK')
#2 D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php(248): Symfony\Component\Debug\ExceptionHandler->escapeHtml('htmlspecialchar...')
#3 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(174): Symfony\Component\Debug\ExceptionHandler->getContent(Object(Symfony\Component\Debug\Exception\FlattenException))
#4 D:\laravels\project\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(115): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(ErrorException))
#' in D:\laravels\project\vendor\symfony\debug\ExceptionHandler.php:412
Stack trace:
#0 {main}