首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在构造方法中调用另一个类构造方法?

如何在构造方法中调用另一个类构造方法?
EN

Stack Overflow用户
提问于 2017-11-21 23:10:01
回答 1查看 126关注 0票数 0

我喜欢在发票类的构造方法中调用FPDF构造类。如何将FPDF cass的构造方法调用到发票类中?

发票类别:

代码语言:javascript
复制
public function __construct($size='A4',$currency='$',$language='en') {
    $this->columns              = 4;
    $this->items                = array();
    $this->totals               = array();
    $this->addText              = array();
    $this->firstColumnWidth     = 70;
    $this->currency             = $currency;
    $this->maxImageDimensions   = array(230,130);
    $this->setLanguage($language);
    $this->setDocumentSize($size);
    $this->setColor("#222222");
    <!-- I want to call here fpdf construct class -->
    $this->FPDF('P','mm',array($this->document['w'],$this->document['h']));
    $this->AliasNbPages();
    $this->SetMargins($this->margins['l'],$this->margins['t'],$this->margins['r']);
}

FPDF类:

代码语言:javascript
复制
function __construct($orientation='P', $unit='mm', $size='A4')
{
    // Some checks
    $this->_dochecks();
    // Initialization of properties
    $this->state = 0;
    $this->page = 0;
    $this->n = 2;
    $this->buffer = '';
    $this->SetCompression(true);
    // Set default PDF version number
    $this->PDFVersion = '1.3';
}
EN

回答 1

Stack Overflow用户

发布于 2017-11-22 15:11:14

通过简单地调用它:

代码语言:javascript
复制
parent::__construct('P','mm', array($this->document['w'],$this->document['h']));

有关更多详细信息,请参阅here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47416361

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档