前提
syntax error, unexpected end of file というエラーが発生したがどうすればこのエラーを解決できるか知りたい
実現したいこと
syntax error, unexpected end of file というエラーを解決したい
発生している問題・エラーメッセージ
syntax error, unexpected end of file
該当のソースコード
Laravel
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> 15$body = '</head><body>'; 16$end = '</body></html>'; 17 18function tag($tag, $txt) { 19 return "<{$tag}>" . $txt . "</{$tag}>"; 20} 21 22class HelloController extends Controller 23{ 24 public function index() { 25 global $head, $style, $body, $end; 26 27 $html = $head . tag('title','Hello/Index') . $style . $body . tag('h1', 'Index').$style 28 .$body.tag('h1','Index') . tag('p','this is Index page').'<a href="/hello/other">go to 29 Other page</a>' . $end; 30 return $html; 31 } 32 33public function other() { 34 global $head, $style,$body,$end; 35 36 $html = $head . tag('title','Hello/Other') . $style . $body .tag('h1','Other').tag('p','this is Other page') 37 .$end; 38 return $html; 39} 40}
試したこと
Laravel エラーsyntax error, unexpected end of file と検索したところ()の閉じ忘れなどが原因らしくもう一度ソースコードに打ち間違えがないか確認した
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
変数の塊を1個ずつ消すなどして試してみてはいかがでしょう
あなたの回答
tips
プレビュー