LoginSignup
1
0

More than 3 years have passed since last update.

名前をつけるときは予約語に注意

Last updated at Posted at 2019-08-16

今回出てたLaravelの開発で出たエラー。結構ハマったのでメモ。

結論:フォルダ名も予約語使わないこと。

PHP Parse error: Syntax error, unexpected T_INTERFACE, expecting T_STRING or '{' on line 1

初めは全体通して動かしてたけど問題の切り分けのために、tinkerで直指定してファイル呼び出し。

php artisan tinker

>>> use App\Infrastructure\Repositories\Interface\IGreetdictionarysRepository;

PHP Parse error: Syntax error, unexpected T_INTERFACE, expecting T_STRING or '{' on line 1

ファイルの中身を全部消してもエラー出るので、フォルダ名を変えた。
Interfaceって名前が予約語なのでIRepositoriesに変えた。

use App\Infrastructure\Repositories\IRepositories;
use App\Infrastructure\Repositories\IRepositories\IGreetdictionarysRepository;

これで通った。

他の言語でも同じように注意

Pythonの予約語に注意

Pythonの変数名で避けた方がいい名前は?
https://qiita.com/matsui2019/items/98165df7bee980ae6a18

MySqlの予約語に注意

MySqlで予約語を使うと、syntax errorが出る
https://qiita.com/ma_me/items/a98842d1cb65bfcd20cf

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0