我有一個cron
文件,服務器每天調用一次。 在該cron文件中,我將require_once()
設置爲具有函數的另一個文件。在那個文件中,我有一個echo
只是爲了讓我知道它被調用。從另一個php文件運行功能
現在,echo
被調用,但不是第二個文件中的函數。
cron.php
error_reporting(E_ALL^E_NOTICE);
ini_set("display_errors", 1);
// external Calendar Sync
$the_file=AC_INLCUDES_ROOT."/ajax/syncExternalCalendar.php";
if(!file_exists($the_file)) die("<b>".$the_file."</b> not found");
else{
require_once($the_file);
}
// other code
cronSyncExternalCalendar(); // this is ignored? or nothing happens
syncExternalCalendar.php
echo 'syncExternalCalendar.php loaded'; echo '<br />'; // this echoes
function cronSyncExternalCalendar(){
echo 'Fired cronSyncExternalCalendar<br />'; // this doesn't(!)
}
外部文件運行巨大的,如果我調用該函數聲明它(在同一個文件)後,當然註釋掉它在cron.php。但我不能讓它從cron.php運行。
任何想法?
我只是測試完全相同的代碼,只移除'AC_INLCUDES_ROOT',它執行就好 –
嗯,看不出有任何理由,是行不通的。如果函數不存在,PHP會發出抱怨,所以如果沒有錯誤,它必須調用該函數。當你從syncExternalCalendar.php中調用函數時,你說這是有效的嗎? – jd182