且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

登录模型尝试登录用户而不是显示登录表单

更新时间:2023-12-04 10:48:34

既然我模型的 NameLogin,那么 login() 方法在其中定义,作为 PHP 的构造函数.

Since my model's Name is Login, then login() method defined in it, acts for PHP as constructor.

这与 Yii 无关,这是 PHP 的基本行为,从旧的、糟糕的 PHP4 继承而来,仅在命名空间类的情况下从 PHP 5.3.3 开始弃用.当类定义不使用命名空间时,这种行为(将构造函数定义为与类同名的函数)仍然有效.

This has nothing to do with Yii, this is a base PHP behavior, inherited from old, bad PHP4 and depracated as of PHP 5.3.3 only in case of namespaced classes. When class definition does not use namespace, this behavior (defining constructor as function named the same way as class) is still valid.

有关详细信息,请参阅此答案或参阅 PHP 手册.

See this answer for more details or refer to PHP manual.