初歩的な質問で申し訳ございません。
laravel入門という本にそってコードを記述していたのですが
エラーが解決できずなかなか次に進めないためご協力お願いいたします。
app/Http/ControllersにHelloController.phpを作成しています。
HelloController.php
1<?php 2 3namespace App\Http\Controllers; 4 5use Illuminate\Http\Request; 6 7global $head, $style, $body, $end; 8$head = '<html><head>'; 9$style = <<<EOF 10<style> 11body {font-size:16pt; color:#999; } 12h1 { font-size:100pt; text-align:right; color:#eee; 13 margin:-40px 0px -50px 0px; } 14</style> 15EOF; 16$body = '</head><body>'; 17$end = '</body></head>'; 18 19function tag($tag, $txt) { 20 return "<{$tag}>" . $txt . "</{$tag}>" 21} 22 23class HelloController extends Controller 24{ 25 26 27 public function index() { 28 global $head, $style, $body, $end; 29 30 $html = $head . tag('title','Hello/Index') . $style . 31 $body . tag('h1','Index') . tag('p','this is Index page') 32 . '<a href="/hello/other">go to Other page</a>' 33 . $end; 34 return $html; 35} 36 37public function other() { 38 global $head, $style, $body, $end; 39 40 $html = $head . tag('title','Hello/Other') . $style . 41 $body 42 . tag('h1','Other') . tag('p','this is Other page') 43 . $end; 44 return $html; 45 46 } 47} 48
routesは下記です。
web.php
1<?php 2 3/* 4|-------------------------------------------------------------------------- 5| Web Routes 6|-------------------------------------------------------------------------- 7| 8| Here is where you can register web routes for your application. These 9| routes are loaded by the RouteServiceProvider within a group which 10| contains the "web" middleware group. Now create something great! 11|/ 12*/ 13 14Route::get('/', function () { 15 return view('welcome'); 16}); 17 18 19Route::get('hello', 'HelloController@index'); 20Route::get('hello/other', 'HelloController@other');
エラー内容。
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_PARSE) syntax error, unexpected '}', expecting ';'
composer dump-autoload等は試してみました。
助言お願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/13 04:25
2018/12/13 04:27
2018/12/13 04:32