From a comment on the question:
Not looking for them to run at the same time. All the files can run one after another. I just need to avoid a fatal error due to the same function names withing the multiple files.
THREEE OPTIONS
Option 1, put the shared functions into a separate file:
<?php
require shared_functions.php
require 1.php
require 2.php
require 3.php
?>
Option 2, wrap function declarations inside a check to see whether the function has been declared already. Requires placing wrapped function declarations before code that calls them:
1.php
<?php
if (!function_exists('shared_function1')):
function 1(){
// yadda yadda
}
endif;
// rest of 1.php
?>
2.php
<?php
if (!function_exists('shared_function1')):
function 1(){
// yadda yadda
}
endif;
// rest of 2.php
?>
If the only problem you are encountering is bombs on function delcarations for functions that already have been declared by another script, make the function names unique (explained at end of this option), then run the scripts with this:
Option 3 - all.php
<?php
$scripts_to_run=array();
$scripts_to_run[]=1.php;
$scripts_to_run[]=2.php;
$scripts_to_run[]=3.php;
.
.
.
$scripts_to_run[]=10.php;
foreach ($scripts_to_run as $script):
require $script;
endforeach;
*TO MAKE THE FUNCTION NAMES UNIQUE, in 1.php, for each sharedfunctionname, search/replace sharedfunctionname with functionname_1 In 2.php, for each sharedfunctionname, search/replace sharedfunctionname with functionname_2 ... etc.
examples:
CURRENT SCRIPTS
1.php
<?php
$var_dry = 'dry';
$var_wet = 'wet';
$result=sharedfunctionname($var_dry, $var_wet);
function sharedfunctionname($var_1, $var_2){
// mix two strings to make one with the letters from both intermingled
}
2.php
<?php
$var_dog = 'dog';
$var_cat = 'cat';
$result=sharedfunctionname($var_dog, $var_cat);
function sharedfunctionname($var_1, $var_2){
// something completely different from mixing two strings....
}
AFTER MAKING FUNCTION NAMES UNIQUE
1.php
<?php
$var_dry = 'dry';
$var_wet = 'wet';
$result=functionname_1($var_dry, $var_wet);
function functionname_1($var_1, $var_2){
// mix two strings to make one with the letters from both intermingled
}
2.php
<?php
$var_dog = 'dog';
$var_cat = 'cat';
$result=functionname_2($var_dog, $var_cat);
function functionname_2($var_1, $var_2){
// something completely different from mixing two strings....
}