php - codeigniter variable as variable using Different Method

$i = 2;
$this->variable2 = "test"; // $this->variable2 is defined
$this->variable= '$this->variable'.$i;
echo ${$this->variable};
Error
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: $this->variable2
Answer
Solution:
This Method Using Different Type of uses.
Finaly i found the solution
Create Variable in one Function method
Update Variable in Another Function method
Call Variable in Different Function methods
But never call Variable name Directly!!!.
public function BWT_start($i){
global $varx;
$varx = 'var'.$i;
return $varx;
}
// Call Global Variable With Different Method with Never call Variable name Directly!!!.
public function BWT_run(){
global $varx;
for($i=1;$i<=7;$i++){
$this->BWT_start($i); //echo Show created Variable Name
$this->BWT_update($i); //echo Show updated Variable value
$this->BWT_process($i); //echo Show Again Changed Variable value
}
}
public function BWT_update($i){
global $varx; global $$varx;
$$varx = "DB_ROW_$i<br>";
return $$varx;
//
}
public function BWT_process($i){
$vary = 'var'.$i;
global $$vary;
$$vary = "DB_UPDATE_$i<br>";
return $$vary;
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.