__construct() vs SameAsClassName() for constructor in PHP

后端 未结 11 2739
南笙
南笙 2020-11-28 09:55

Is there any advantage to using __construct() instead of the class\'s name for a constructor in PHP?

Example (__construct):



        
11条回答
  •  萌比男神i
    2020-11-28 10:10

    The main advantage I see for __construct, is that you don't have to rename your constructor if you change your class name.

提交回复
热议问题