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

<?php

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

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

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

posted @ 2013-10-15 23:04  无忧之路  阅读(630)  评论(0编辑  收藏  举报
无忧之路