前提・実現したいこと
ここに質問の内容を詳しく書いてください。
LARACASTでPHPの講座を受講しています。
index.phpで定義した変数をindex.view.phpで出力する。
しかし、画面には何も表示されません。
index.view.phpでechoはされます。
index.view.phpにgreeting変数がないことは理解しています。
変数を定義しているのはindex.phpです。
ファイルの場所はhtdocs直下です。
MAMP/htdocs
よろしくお願い致します。
発生している問題・エラーメッセージ
Notice: Undefined variable: greeting in /Applications/MAMP/htdocs/index.view.php on line 13
該当のソースコード
PHP
1~index.view.php~ 2 3<!DOCTYPE html> 4<html lang="ja"> 5<head> 6 <meta charset="UTF-8"> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 9 <title>Document</title> 10</head> 11<body> 12 <h1><?php echo $greeting; ?></h1> 13</body> 14</html> 15
PHP
1~index.php~ 2 3<?php 4 5$greeting = 'Hello, World'; 6 7require 'index.view.php'; 8
試したこと
1.下記のサイトでconf/apache/httpd.confを編集しました。
https://qiita.com/FJHoshi/items/c5ff14c79b1ffd85cb14
2.xamppでも同じ処理を実行したが表示されません。
補足情報(FW/ツールのバージョンなど)
phpバージョン -> 7.3.1
回答1件
あなたの回答
tips
プレビュー