面向对象
<?php class phpClass{ var $name=12; var $sex="boy"; function __construct($a='default',$b=12){ echo $a."\n"; } function say(){ return $this->name; } } $p=new phpClass(); echo $p->say(); echo (new phpClass('bbbb'))->say()."\n"; ?>
构造函数
<?php class MyClass{ function __construct(){ echo "aa\n"; } } $my=new MyClass(); ?>