[タイポ] php PHP Warning: Use of undefined constant DB_HOST – assumed ‘DB_HOST’ (this will throw an Error in a future version of PHP) in /home/hoge/hoge/index.php on line n | クズリーマンのカス備忘録

[タイポ] php PHP Warning: Use of undefined constant DB_HOST – assumed ‘DB_HOST’ (this will throw an Error in a future version of PHP) in /home/hoge/hoge/index.php on line n

php-logo php
スポンサーリンク

 

 

事象

自分で作ったphpプログラム を実行したら以下のエラーが出力された。

PHP Warning: Use of undefined constant DB_HOST - assumed 'DB_HOST' (this will throw an Error in a future version of PHP) in /home/hoge/hoge/index.php on line 3

 

定数「DB_HOST」を定義しているところで失敗している。

原因

ソースコードを見たら以下の様に書いてた。

define(DB_HOST, 'db');

。。。

うん、ただのタイポだね。

DB_HOST は文字列にせなアカン。

 

よくこれで動いたなー。

(this will throw an Error in a future version of PHP)

↑将来的には動かなくなるということですが。

対応

define('DB_HOST', 'db');

こう直した。

 

 

 

 

 

 

 

 

コメント

タイトルとURLをコピーしました