質問編集履歴
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
http://localhost/xxxxx/resources/views/index.blade.php
|
3
3
|
XAMP環境で上記URLに飛んでも変数名のまま表示されました。
|
4
4
|
URLの指定の仕方が間違っていますか?教えてください。
|
5
|
+
php artisan serve --host 0.0.0.0
|
6
|
+
でサーバーたててhttp://localhost:8000/helloにアクセスすると正しく表示されます・・・
|
5
7
|
|
6
8
|
HelloController.php
|
7
9
|
```php
|
2
現状の内容
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,10 +16,11 @@
|
|
16
16
|
public function index ()
|
17
17
|
{
|
18
18
|
$hello = 'Hello,World!';
|
19
|
-
return view('index', $hello);
|
19
|
+
return view('index')->with('hello', $hello);
|
20
20
|
}
|
21
21
|
}
|
22
22
|
|
23
|
+
|
23
24
|
```
|
24
25
|
|
25
26
|
```php
|
@@ -27,7 +28,7 @@
|
|
27
28
|
return view('welcome');
|
28
29
|
});
|
29
30
|
|
30
|
-
Route::get('
|
31
|
+
Route::get('hello', 'HelloController@index');
|
31
32
|
```
|
32
33
|
|
33
34
|
```html
|
1
書いたコード
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,44 @@
|
|
1
1
|
[LaravelでHallo,worldを出力する資料](https://qiita.com/ekzemplaro/items/482ea99e3548029eaf18)を読んで簡単なコントローラー、view,ルーティングをしましたが、変数名のまま表示されて値の受け渡しができていませんでした。
|
2
2
|
http://localhost/xxxxx/resources/views/index.blade.php
|
3
3
|
XAMP環境で上記URLに飛んでも変数名のまま表示されました。
|
4
|
-
URLの指定の仕方が間違っていますか?教えてください。
|
4
|
+
URLの指定の仕方が間違っていますか?教えてください。
|
5
|
+
|
6
|
+
HelloController.php
|
7
|
+
```php
|
8
|
+
<?php
|
9
|
+
|
10
|
+
namespace App\Http\Controllers;
|
11
|
+
|
12
|
+
use Illuminate\Http\Request;
|
13
|
+
|
14
|
+
class HelloController extends Controller
|
15
|
+
{
|
16
|
+
public function index ()
|
17
|
+
{
|
18
|
+
$hello = 'Hello,World!';
|
19
|
+
return view('index', $hello);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
```php
|
26
|
+
Route::get('/', function () {
|
27
|
+
return view('welcome');
|
28
|
+
});
|
29
|
+
|
30
|
+
Route::get('index', 'HelloController@index');
|
31
|
+
```
|
32
|
+
|
33
|
+
```html
|
34
|
+
<!DOCTYPE html>
|
35
|
+
<html lang="ja">
|
36
|
+
<head>
|
37
|
+
<meta charset="UTF-8">
|
38
|
+
<title>My First Page</title>
|
39
|
+
</head>
|
40
|
+
<body>
|
41
|
+
<p>{{$hello}}</p>
|
42
|
+
</body>
|
43
|
+
</html>
|
44
|
+
```
|