share a property in different functions within a same class in php wordpress

27 Views Asked by At

I have this code example, where I am not receiving the value of $something in the passData() function, since null comes, what is happening, this is code example:

class ClassName extend X {

     private $something;

     public function __construct() {
         parent::__construct();
         add_filter( 'woocommerce_before_checkout_form', array($this,
         'createText') );
     }

     function createText() {
         $property = 'xthing';
         $this->something = $property;
         return $this->something;
     }

     public function passData() {
         $somethingMore=$this->something;
     }
}

i expecting $something get data in function passData()

0

There are 0 best solutions below