LoginSignup
10
8

More than 5 years have passed since last update.

Fatal error: Cannot redeclareのよくある原因

Posted at

定番の原因

  • 同じ関数名を定義している
  • 2回includeしてる(2回読み込み)

見つけにくい2回include

① index.php ← A.php, B.php 

② A.php   ←   B.php

①index.phpがA.phpとB.phpをinclude
②A.phpがB.phpをinclude

コメント

極めてくだらないが、見つからなかったりする。
include文を一つずつコメントアウトして、どのファイルとどのファイルが同じ物を読み込んでいるかを検証するとすぐ気づける

10
8
2

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
10
8