我正在研究其他開發人員開發的腳本。有它發送電子郵件警報系統,並且每個模塊有自己的警示文件和警報文件require_once
PHPMailer的文件的多個require_once
<?php
// assume this is 1.php
//.......... some code above //
$mail_title = 'Message Title';
$mail_body = 'Message body with complete details what has been done here';
require_once 'module_alert.php'; // <- PHP Mailer is requir_once in this file
//........... ajax and some response //
?>
只要我require_once它生成的電子郵件和派遣這一點。
現在我必須更新模塊中的PHP頁面。該頁面必須將數據發佈到3個不同的php頁面模塊。在該頁面僅向一個PHP頁面VIA ajax發送數據之前,其他兩個頁面使用First First的自動遞增ID。
由於複雜性,我想包括其他兩個文件以及文件1
<?php
// assume this is 1.php
//.......... some code above //
$mail_title = 'Message Title';
$mail_body = 'Message body with complete details what has been done here';
require_once 'module_alert.php'; // <- PHP Mailer is requir_once in this file
//........... ajax and some response //
if($condition){
include '2.php'; // <- this file again require_once 'module_alert.php'
include '3.php'; // <- this file again require_once 'module_alert.php'
}
?>
的問題是,我想對所有3個步驟發送警報,並且還我不想改變其他文件中的大量代碼可能會破壞腳本。
在這種情況下我有什麼選擇可以存活下來?
編輯
在module_alerts.php
有東西數量。郵件佈局,表格圖像,條件接收者,誰應該獲得這個模塊的警報等。$ mail-> send()函數,以便發送電子郵件給特定的接收者。
我想建議將require_once替換爲require ...但wtf是在module_alert.php中嗎? – ajreal
我已經更新了你的問題。 :) –