【发布时间】:2018-06-21 14:13:35
【问题描述】:
对不起,英语不是我的母语。
我正在尝试将数组传递给函数。该数组包含确定的三个月的三个月。这段代码是关于FPDF的,我在做PDF报告。
这是代码:
<?php
include('../../../libreria/engine.php');
require_once('../fpdf.php');
$mes = $_GET["txtMes"];
$per = $_GET["txtPer"];
$_SESSION["tmpMes"] = $_SESSION["sqlDataPDF"]["titulo"];
$sql = $_SESSION["sqlDataPDF"]["textoSQL"];
$mes = $_SESSION["sqlDataPDF"]["meses"];
echo $mes[0];
$rs = mysql_query($sql);
class Anexo03 extends FPDF
{
var $ProcessingTable; //Es la propiedad que indica si se esta procesando la tabla, para repetir nuevamente el encabezado.
var $anchos; // Son los anchos de las diferentes columnas
var $left; //Margen izquierdo inicial
var $clasificador;
function Header()
{ //0 1 2 3 4
$this->anchos = array(100, 20, 30);
$this->left = 15;
$this->ProcessingTable = true;
//Print the table header if necessary
}
function TableHeader($clasificador='x', $y=38, $c=false)
{
if($c)
{
$clasificador = $this->clasificador;
}
$this->clasificador = $clasificador;
$alto = 6; //Es el alto de la linea
$this->SetFillColor(209,211,223);
$this->SetFont('Arial','',10);
$this->SetXY($this->left,$y);
$ancho = $this->anchos[0] + $this->anchos[1] + $this->anchos[2] + $this->anchos[3];
//$this->Cell($ancho,$alto,"Clasificador: $clasificador", 'LRT',0,'L',1);
//$this->SetXY($this->left,$y+4);
$this->Cell($this->anchos[0],$alto,"Clasificador", 'LBT',0,'C',1);
$this->Cell($this->anchos[1],$alto,'$mes[0]', 'RBT',0,'C',1);
$this->Cell($this->anchos[1],$alto,'$mes[1]', 'RBT',0,'C',1);
$this->Cell($this->anchos[1],$alto,'$mes[2]', 'RBT',0,'C',1);
$this->Cell($this->anchos[2],$alto,"Total Trimestral", 'RBT',0,'C',1);
}
此代码正在接收数组。我可以毫无问题地回显变量$mes,我可以看到数据,当我放入function TableHeader时问题就来了。我尝试var_dump 和echo 变量$mes 但var_dump 给我null 和echo 什么都不做。就像我将数组放入函数中时缺少数据一样。
我正在尝试不同的方法在函数内部传递变量$mes,也许我做得不好。
你觉得我能做什么?
【问题讨论】:
-
参见:variable scope ...
mysql_扩展名也已失效 - 不要使用它。 -
@CD001 我现在就去读!是的,我将使用 mysqli。谢谢
标签: php mysql pdf session-variables fpdf