开发者

Life time of Objects in Wordpress

I have prev开发者_如何学Ciously asked about life time of objects on stackoverflow and came to know that they exist until the end of script, i tested it and it was true. But in case of wordpress the Objects life for a longer time. Like the user object, i can access it on any page and on any script even if it is not instantiated on that particular script.

What is the reason behind that?


The reason is, that in fact you have two objects. The data of the user comes from the database and if the user is logged in, the API functions of wordpress will give you an object with the data from the database.

As the data from the database has not changed, you can get a quadrillion user objects on a quadrillion pages. However each of these objects lives only for one request or until unset.

To have user objects on any page available, wordpress is storing the data of each user into the database. The database keeps the data for a longer time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜