質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,10 @@
|
|
5
5
|
XAMP環境で上記URLに飛んでも変数名のまま表示されました。
|
6
6
|
|
7
7
|
URLの指定の仕方が間違っていますか?教えてください。
|
8
|
+
|
9
|
+
php artisan serve --host 0.0.0.0
|
10
|
+
|
11
|
+
でサーバーたててhttp://localhost:8000/helloにアクセスすると正しく表示されます・・・
|
8
12
|
|
9
13
|
|
10
14
|
|
2
現状の内容
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,11 +34,13 @@
|
|
34
34
|
|
35
35
|
$hello = 'Hello,World!';
|
36
36
|
|
37
|
-
return view('index', $hello);
|
37
|
+
return view('index')->with('hello', $hello);
|
38
38
|
|
39
39
|
}
|
40
40
|
|
41
41
|
}
|
42
|
+
|
43
|
+
|
42
44
|
|
43
45
|
|
44
46
|
|
@@ -56,7 +58,7 @@
|
|
56
58
|
|
57
59
|
|
58
60
|
|
59
|
-
Route::get('
|
61
|
+
Route::get('hello', 'HelloController@index');
|
60
62
|
|
61
63
|
```
|
62
64
|
|
1
書いたコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,3 +5,83 @@
|
|
5
5
|
XAMP環境で上記URLに飛んでも変数名のまま表示されました。
|
6
6
|
|
7
7
|
URLの指定の仕方が間違っていますか?教えてください。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
HelloController.php
|
12
|
+
|
13
|
+
```php
|
14
|
+
|
15
|
+
<?php
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
namespace App\Http\Controllers;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
use Illuminate\Http\Request;
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
class HelloController extends Controller
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
public function index ()
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
$hello = 'Hello,World!';
|
36
|
+
|
37
|
+
return view('index', $hello);
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
```php
|
50
|
+
|
51
|
+
Route::get('/', function () {
|
52
|
+
|
53
|
+
return view('welcome');
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Route::get('index', 'HelloController@index');
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
```html
|
66
|
+
|
67
|
+
<!DOCTYPE html>
|
68
|
+
|
69
|
+
<html lang="ja">
|
70
|
+
|
71
|
+
<head>
|
72
|
+
|
73
|
+
<meta charset="UTF-8">
|
74
|
+
|
75
|
+
<title>My First Page</title>
|
76
|
+
|
77
|
+
</head>
|
78
|
+
|
79
|
+
<body>
|
80
|
+
|
81
|
+
<p>{{$hello}}</p>
|
82
|
+
|
83
|
+
</body>
|
84
|
+
|
85
|
+
</html>
|
86
|
+
|
87
|
+
```
|