“Fatal error: Cannot redeclare

前端 未结 17 1145
[愿得一人]
[愿得一人] 2020-11-22 05:26

I have a function(this is exactly how it appears, from the top of my file):



        
17条回答
  •  感动是毒
    2020-11-22 06:21

    Solution 1

    Don't declare function inside a loop (like foreach, for, while...) ! Declare before them.

    Solution 2

    You should include that file (wherein that function exists) only once. So,
    instead of :  include ("functions.php");
    use:             include_once("functions.php");

    Solution 3

    If none of above helps, before function declaration, add a check to avoid re-declaration:

    if (!function_exists('your_function_name'))   {
      function your_function_name()  {
        ........
      }
    }
    

提交回复
热议问题