php初心者です。
vagrantで開発環境を構築し、ドットインストールの「phpでビンゴシートを作ろう」に挑戦しているのですが、以下のエラーメッセージが出てどうしてもブラウザで表示されません。
Parse error: syntax error, unexpected '$nums' (T_VARIABLE) in /vagrant/html/Bingo.php on line 13
returnで変数$numsが戻り値として返っていないようですが、動画を見ても間違いがないように思います。
なぜ表示できないか教えていただけないでしょうか?
コード
file:Bingo.php
<?php namespace MyApp; class Bingo { public function create(){ $nums=[]; for($i=0;$i<5;$i++){ $col =range($i*15+1,$i*15+15); shuffle($col); $nums[$i] = array_slice($col,0,5); } $nums[2][2] ="FREE"; retrun $nums; } }
file:index.php
<?php require_once(DIR.'/config.php'); require_once(DIR.'/Bingo.php'); $bingo = new \MyApp\Bingo(); $nums = $bingo->create(); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>BINGO</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div id="container"> <table> <tr> <th>B</th><th>I</th><th>N</th><th>G</th><th>O</th> </tr> <?php for($i =0;$i<5;$i++): ?> <tr> <?php for($j=0;$j<5;$j++): ?> <td><?= h($nums[$j][$i]); ?></td> <?php endfor; ?> </tr> <?php endfor; ?> </table> </div> </body> </html>
回答1件
あなたの回答
tips
プレビュー