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?

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.

I doubt this is an actual code, but it looks like variable scope problem - $image1 is not defined inside header function, so FPDF is trying to use empty string and fails as described in given error.