假设我有如下 PHP 函数:
函数.php
<?php
function getDataInFile($PMTA_FILE){
$PMTA_DATE = date("Y-m-d");
$lineFromText = explode("\n", $PMTA_FILE);
$number_bar_charts = 13;
$row = 0;
$cate = "";
$total ="";
$fail = "";
$mailSuc = "";
$title = "";
foreach($lineFromText as $line){
if($row < $number_bar_charts){
$words = explode(";",$line);
$dateTime .= ','.$words[0];
if($title == ""){
$title = $words[0];
}
$cate .= ','."'$words[5]'";
$total .= ','.$words[6];
$fail .= ','.$words[7];
$mailSuc .= ','.((int)$words[6] - (int)$words[7]);
$row++;
}
}
}
?>
这是下面的代码,我调用该函数在getFile.php
.
<?php
include("include/function.php");
$PMTA_DATE = date("Y-m-d");
getDataInFile("../stats_domain_recepteur.affinitead.net.".$PMTA_DATE.".txt");
?>
实际上,它无法从文件中读取数据,我收到了错误消息Undefined variable: dateTime in C:\wamp\www\chat\include\function.php on line 15
,Notice: Undefined offset: 5 in C:\wamp\www\chat\include\function.php on line 19
....
我不知道如何解决这个问题,请任何人帮助我,谢谢。