Below by# column for everyone to remember the mistakes of sharing variables once, I hope to help friends who need it!
The problem occurs
In models/User. php
var UserModel = new (User)
Controller
if models.UserModel.Token == "" { models.UserModel.Token = "hello world" }
Becausevar UserModel = new (User)
will onlynew
Once, this variable is shared with each request.
As a result, thisif
will only be executed once in the future, or it can only obedientlynew
a new pointer.
obedientnew
var UserModel = new (models.User) if UserModel.Token == "" { UserModel.Token = "hello world" }
Ending
It took several hoursdebug
to find the problem, and I made a basic mistake.
The above is the detailed content of Remember a mistake made because of shared variables. For more information, please follow other related articles on the PHP Chinese website!