0
 class Test {
 
   public $num1;   public $num2;
 
   public function __construct($number1,$number2){
 
     $this->$num1 = $num1;
     $this->$num2 = $num2;   }
 
    public function divid(){
 
    
     $res =  $this->$num1 / $this->$num2;
 
     return $res;    }
 
    public function methodExp(){
 
 
     
     $resOfPow = exp($this->$num1, $this->$num2);
 
     return $resOfPow;    } 
}

$resultTest = new Test(10,5); 

 var_dump($resultTest);
 
 object(Test)[1]   public 'num1' => null   public 'num2' => null  
 public '10' => int 10   public '5' => int 5

echo $resultTest->divid();

When i call method php eroro show me undefined varibale on $num1 and $num2 as if he had never set values from __construct, and i do not why?

Alon Eitan
  • 11,997
  • 8
  • 49
  • 58
Sava
  • 113
  • 1
  • 13

0 Answers0