I'm running into a problem including this function from another file
function sendRes($s_attachment) //this is line 3
{
/*Snip : processing message details..*/
try {
mail($to, $subject, $message, $headers);
} catch (Exception $e) {
logMessage("An error occured:" . $e->getMessage());
}
} //this is line 54
When running the script, it outputs the following error
Fatal error: Cannot redeclare sendRes() (previously declared in **********\email.php:3) in ***********\email.php on line 54
But it's declared only once, I checked that the file is included only once too. And the file contains only this function.
Any clues about why this isn't working ?
remove the block of code you included and see what the code below returns.
var_dump(function_exists('send_res'));
If you get false, you're including the file with that function twice, replace:
include
with include_once
and replace require
with require_once
.
Another alternative, put your code in this if statement like this:
if (!function_exists('sendRes')) {
function sendRes($s_attachment) //this is line 3
{
/*Snip : processing message details..*/
try {
mail($to, $subject, $message, $headers);
} catch (Exception $e) {
logMessage("An error occured Sending fingerprint:" . $e->getMessage());
}
} //this is line 54
}
Wrap it with
if(function_exists('function_name')) {
}
http://php.net/manual/en/function.function-exists.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With