您将在下面看到的是用于在月底生成报告的代码,这是一个用于单击以生成报告的按钮,并根据月份和年份进行排序。
这个文件可以工作,但我在标题部分有一个问题,这是代码:
//Title
$this->SetFont('Arial','',18);
$this->Image('media/logo.png');
$this->Ln(10);
$this->Cell(0,6,'Generated Reports',0,1,'C');
$this->Cell(0,7,'As of Month of ',0,2,'C');
if($date=="01")
{
$pdf->Cell(0,8,'January',0,3,'C');
}
else if($date=="02")
{
$pdf->Cell(0,8,'February',0,3,'C');
}
else if($date=="03")
{
$pdf->Cell(0,8,'March',0,3,'C');
}
else if($date=="04")
{
$pdf->Cell(0,8,'April',0,3,'C');
}
else if($date=="05")
{
$pdf->Cell(0,8,'May',0,3,'C');
}
else if($date=="06")
{
$this->Cell(0,8,'June',0,3,'C');
}
else if($date=="07")
{
$this->Cell(0,8,'July',0,3,'C');
}
else if($date=="08")
{
$this->Cell(0,8,'August',0,3,'C');
}
else if($date=="09")
{
$this->Cell(0,8,'September',0,3,'C');
}
else if($date=="10")
{
$this->Cell(0,8,'October',0,3,'C');
}
else if($date=="11")
{
$this->Cell(0,8,'November',0,3,'C');
}
else if($date=="12")
{
$this->Cell(0,8,'December',0,3,'C');
}
$this->Ln(10);
//Ensure table header is output
parent::Header();日期是以数字表示的,因此1月是01Feb= 02,依此类推,直到12月= 12。
正如您在上面看到的,我尝试使用if,甚至将$this更改为$pdf,但仍然无效。
它将生成一个PDF文件,但没有月份,它将只生成“截至月份”和它下面的详细信息,而不是生成它的月份。
发布于 2014-04-27 10:29:47
不要混合使用$this(类成员)和$pdf(类对象)
//Title
$this->SetFont('Arial','',18);
$this->Image('media/logo.png');
$this->Ln(10);
$this->Cell(0,6,'Generated Reports',0,1,'C');
$monthArray = array("January","February","March","April","May","June","July","August","September","October","November","December");
$index = intval($date)-1;
$this->Cell(0,7,'As of Month of '.$monthArray[$index],0,2,'C');
$this->Ln(10);
//Ensure table header is output
parent::Header();https://stackoverflow.com/questions/23306222
复制相似问题