小编use*_*465的帖子

如何解决"非静态方法xxx :: xxxx()不应该静态调用"

我有一个PHP文件,下面的代码,我收到错误:

严格的标准:非静态方法LinkCore :: getImageLink()不应该静态调用,假设$ this来自不兼容的上下文....

但如果我改变这一行:

$product_image = Link::getImageLink($product->link_rewrite[1], (int)$images[0]['id_image'], 'large_default');
Run Code Online (Sandbox Code Playgroud)

$product_image = Link->getImageLink($product->link_rewrite[1], (int)$images[0]['id_image'], 'large_default');
Run Code Online (Sandbox Code Playgroud)

我明白了

第44行的/xxx/xxx/public_html/modules/supplierreports/HTMLTemplateCustomPdf.php中的解析错误:语法错误,意外的' - >'(T_OBJECT_OPERATOR)

如果我用"public static"声明所有函数,我会在类HTMLTemplateCustomPdf中得到错误"致命错误:无法使非静态方法HTMLTemplateCore :: getContent()静态"

那么我该怎么做才能解决这个问题呢?

<?php
class HTMLTemplateCustomPdf extends HTMLTemplate
{
public $supplier;
public function __construct($supplier_order, $smarty)
{
    //print_r($supplier_order);
            $this->supplier_order = $supplier_order;
            $this->supplier = new Supplier((int)$this->supplier_order->id_supplier);
            //$this->supplier_orders = $this->supplier_order->orders
    $this->smarty = $smarty;

            // header informations
            $id_lang = Context::getContext()->language->id;
            $this->title = HTMLTemplateCustomPdf::l('Supplier ').' : '.$this->supplier->name;

    // footer informations
    $this->shop = new Shop(Context::getContext()->shop->id);
}
/**
 * Returns the template's HTML content …
Run Code Online (Sandbox Code Playgroud)

php static-methods

2
推荐指数
1
解决办法
4637
查看次数

标签 统计

php ×1

static-methods ×1