php
1 2<?php 3 4namespace App\Http\Controllers; 5 6use Illuminate\Http\Request; 7 8 9 10 11global $head, $style,$body,$end; 12$head ='<html><head>'; 13$style = <<< EOF 14<style> 15body{font-size:16pt;} 16h1{font-size:80pt;} 17 18</style> 19EOF; 20$body = '</head><body>'; 21$end = '</body></head>'; 22 23 24function tag($tag,$txt){ 25 26 return "<$tag>" . $txt . "/{$tag}"; 27} 28 29 30 31class HelloController extends Controller 32{ 33public function index(){ 34global $head, $style,$body,$end; 35 36$html = $head . tag('title','Hello/Index') . $style 37. $body . tag('h1','Index') .tag('p','This is sample page') . '<a href="/hello/other"> 38go to Other page</p> ' .$end; 39 40 return $html; 41} 42 43 44public function other(){ 45 46global $head, $style,$body,$end; 47 48$html = $head . tag('title','Hello/Other') . $style 49. $body . tag('h1','Other') .tag('p','This is Other page') . $end; 50return $html; 51 52}} 53
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' ); 21 22
コントローラ(上)とルーティング(下)のコードを書いてみたのですが
画面に何も表示されません。
原因が分からなかったのでアドバイス頂けると助かります
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/05/26 14:48
2019/05/26 14:54
退会済みユーザー
2019/05/26 14:58
2019/05/26 15:15
2019/05/27 00:22
2019/05/27 12:17
2019/05/27 12:25 編集