Guys, why can this code get the user name? ! !
rain
rain 2020-02-11 20:57:28
0
3
1088

I have a few questions:

1 Shouldn’t $user, the automatically loaded construct, be empty?

is to call $this->user->name in the hello method, so what you get is also empty.

Why is it written like this?

image.png

rain
rain

reply all (2)

The parameter of the constructor method is required to be a userModel object. If this object has the attribute name, it can be $this->user->name.

  • reply Yes
    rain author 2020-02-16 10:41:45
小梨

An error will be reported. In the construction method, did you pass user in the new object (did you pass it in)?

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!