来自变量的PHP类名

Can I dynamically name a class?

I have written a process which calls about 6 pages that generate pdfs through tcpdf. They all use the same header page which makes a class.

class myPDF extends TCPDF {

the problem is when i run my script I get Fatal error: Cannot redeclare class myPDF in after the first page is done.

I understand why but am at a loss how to deal with it.

calling it only once is no good as it holds a function which looks at page specific variables.

I also don't think I can UNdeclare it in anyway.

Once way would be to change the class name for each include but not sure how to make the class name a variable?

ie class $newname

Any ideas

S

Added this

class myPDF extends TCPDF {
public function Header () {

global $title;
global $client;
global $host;


$oMulticell->multiCell(266,8, "<s1>$title&nbsp;     Client:</s1> <s2>$client</s2>     <s1>Host:</s1> <s2>$host</s2>     <s1>Currency:</s1> <s2>$currency</s2>     <s1>Reporting Period:</s1> <s2>$start_date_rep to $end_date_rep</s2>", 'TB');
}

You can't. Class definition has to be parsable in compile-time, and not in run-time. You can't make a "dynamic" class name.

include_once(); should fix your problem.