Fatal error: Cannot redeclare _requireoncefileexists() (previously declared in functions.php:3) in functions.php on line 3

I have checked my code and do not see any redeclaration of my function anywhere. I have it being called upon in index.php (the file which is giving me that error).

Any help or suggestions would be appreciated! Thanks!

index.php

<?php
/* Include the ban file and make sure they are not banned. */
require_once("ban.php");
include("functions.php");
require("config.php");
/* index.php */

if ($temp_down == 1) { 
_requireonceFileExists("error.inc.php");
} else {
if (isset($_GET['out'])) { 
header('location: '.$_GET['out']); 
}
switch($_GET['x']) {
case "hsia":
include("hsia.inc.php");
break;
case "vm":
include("vm.inc.php");
break;
case "ca":
include("ca.inc.php");
break;
case "ps":
include("ps.inc.php");
break;
case "l":
include("l.inc.php");
break;
case "error":
include("error.inc.php");
break;
default:
require("index.php");
} 
}
?>

functions.php

<?php
/* functions.php */
function _requireonceFileExists($file) {//start
if (file_exists("$file")) {
	require_once("$file");
} else {
	print "Fatal Error: Cannot require $file<br />";
	exit();
}
}//end

function _requireFileExists($file) {//start
if (file_exists("$file")) {
	require("$file");
} else {
	print "Fatal Error: Cannot require $file<br />";
	exit();
}
}//end

function _includeFileExists($file) {//start
if (file_exists("$file")) {
	include("$file");
} else {
	print "Unable to include $file <br />";
}
}//end

?>

    Found the issue, I was requiring index.php again which, in retrospect, redeclared my functions.

      hey,

      using "require_once" can help avoid such problems, ... however avoid having "require_once" in the function's block:

      <?php
      
      function _foo()
      {
           require_once('myincludefile.php');  //bad 
      }
      
      ?>
        Write a Reply...