Как обновить функцию другого класса из другого класса - PullRequest
0 голосов
/ 13 сентября 2018

Я могу вызвать функцию из другого класса, но не могу обновить / перезаписать ее из другого класса. Есть ли способ обновить функцию другого класса в другом файле из функции другого класса в другом файле. спасибо

file A.php

    class FPDF{

        function header{

            //some code

        }

    }

file B.php

    Class Users extents basecontroller{

        function viewPDF{

            require_once(A.php)

            $pdf = new FPDF

            $pdf->Header()

        }

    }

    require_once(A.php);
    Class PDF extends FPDF
    {
        // Page header
        function Header()
        {
            // Logo
            // Line break
            $this->Ln(100);
        }
     }

1 Ответ

0 голосов
/ 13 сентября 2018

Я думаю, что структура ваших файлов должна быть чем-то вроде

file A.php
    class FPDF{
        function header{
            //some code
        }
    }


file library/Pdf.php
    require_once(A.php);
    Class Pdf extends FPDF
    {
        // Page header
        function Header()
        {
            // Logo
            // Line break
            $this->Ln(100);
        }
     }  


file Users.php
    Class Users extents basecontroller{
        function viewPDF{
            $this->load->library('pdf');
            $this->pdf->Header()
        }
    }
...