douguai4653 2012-02-20 17:40
浏览 54
已采纳

FPDF - 变量不起作用

I am trying to set the following image as a variable.

I get this error when accessing the pdf: FPDF error: Image file has no extension and no type was specified:

Here is my code:

$image1 = "../storage/$_GET[id]/01.jpg";

function Header()
{

$this->Image($image1,10,8,33);

}

anything wrong in it?

  • 写回答

2条回答 默认 最新

  • duanche5149 2012-02-20 18:26
    关注

    If the code you posted it's your actual code, try:

     $image1 = "../storage/{$_GET['id']}/01.jpg";
    

    Please read here;

    Anyway, if $_GET['id'] must be a integer value, it's better to avoid security issues using:

     $image1 = '../storage/' . intval($_GET['id']) . '/01.jpg';
    

    Read here and here.

    Also, as dev-null-dweller said, global variables aren't visible inside functions. In that case, fix it using:

    $image1 = '../storage/' . intval($_GET['id']) . '/01.jpg';
    
    function Header() {
        global $image1;
        $this->Image($image1, 10, 8, 33);
    }
    

    And have a look here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测