search

Home  >  Q&A  >  body text

tp5 variable calling problem in different controllers

Assume there is an A controller and a B controller. How can the variables defined in the A controller be called by the B controller after being assigned by the function of the A controller? I've tried using global variables, but it doesn't work either. Please give me an answer!

陈华强陈华强1827 days ago1290

reply all(2)I'll reply

  • Storms

    Storms2020-05-14 12:55:32

    Inheritance of controller class

    reply
    0
  • 路边的小蚂蚁i

    路边的小蚂蚁i2020-05-09 10:29:43

    Let controller B inherit controller A

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    class A {

        public $a;

        public function __construct() {

            $this->a = 1;

        }

    }

     

    class extends A {

        public function fb() {

            echo $this->a;

        }

    }

    reply
    0
  • Cancelreply