How does an operation method under the same controller in TP call a variable in another operation method?

what if b wants to use the $time variable in a?

   public function a(){
      $time="1520452015";
      return $this->fetch();
   }
   public function b(){
     
   }
Mar.22,2021

  1. return $time as a return parameter
  2. set $time to the class variable $this- > time

Encapsulation learn about

public $time = '1520452015';
public function a()
{
  $time = $this->time;
  return $this->fetch();
}
public function b()
{
    var_dump($this->time);
}

you can put time in the properties of this class. A modifies the


private $time = 'xxxxx';
public function a()
{
  $time = $this->time;
  return $this->fetch();
}
public function b()
{
    dump($this->time);
}


private static $time = 'xxxxx';
public function a()
{
  $time = self::$time;
  return $this->fetch();
}
public function b()
{
    dump(self::$time);
}
that can also be read by b.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e42165-44986.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e42165-44986.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?