php构造函数construct用法注意事项

<?php

class A
{
  //特别注意,这里的下划线为两个
function __construct() { echo "I am the constructor of A.<br> "; } function B() { echo "I am a regular function named B in class A.<br> "; echo "I am not a constructor in A.<br> "; } } $a = new A(); ?>

construct构造函数前面的下划线为两个。

当实例一个对象的时候,该构造函数会自动调用。

原文地址:https://www.cnblogs.com/wuyou/p/3371257.html