Initialize the assignment inside a constructor. After that make an instance of class B and you can right away call the method which is in class A.
FYI : The variable $a
is made as public.
The code...
<?php
class A
{
private $variable1;
private $variable2;
public function show()
{
echo "Hi";
}
}
class B
{
public $a;
private $variable3;
private $variable4;
function __construct()
{
$this->a = new A;
}
}
$b = new B;
$b->a->show(); // prints Hi