I have a question how to call a variable.
In Js, if I write $A = $this->A
inside of B()
, I could reach $this->A
through $A
inside of C()
; But in PHP seem like this way will not work.
Please advice a way that can read $this-A inside of C() without give function variable.
class X {
function B(){
function C(){
$this->A; // Can not call A here
$A; // No work either
}
$A = $this->A; //
$this->A; // Can call A here
}
private $A;
}
This one here is Global $A
Get variables from the outside, inside a function in PHP
However,if global, the global here means the entire script not within the class.
Thank you very much for your advice.