Welcome Guest, Not a member yet? Register   Sign In
How to use a protected function from another class
#1

Class A
PHP Code:
<?php
namespace App\Controllers;
use 
CodeIgniter\Controller;
class 
extends Controller
{
    protected function 
a()
    {
        return 
'a';

    }


Class B:
PHP Code:
<?php
namespace App\Controllers;
use 
CodeIgniter\Controller;
use 
App\Controllers\A;
class 
Test extends Controller
{
    private 
$a;
    function 
__construct()
    {
        
$this->a= new A();
    }
    function 
b(){
        
$b $this->a->a();
        return 
$a;
    }


Error
Call to protected method...

How can I get the 'a' in Class B
Reply


Messages In This Thread
How to use a protected function from another class - by JerryCode - 08-03-2020, 02:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB