php class name is the same as method name

php When the class name is the same as the method name, the method becomes a constructor. At this point, instantiate the class, then the program automatically executes this method.

  • If the class also has a constructor: __construct( ), then the method with the same name as the class will not be executed.
  • Of course, using namespace: namespace, the method with the same name as the class name will become a normal method.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325485458&siteId=291194637