要初始化object变量,您使用下面例子中所示的申明方法: class foo { function do_foo () { echo "Doing foo."; } } $bar = new foo; $bar -> do_foo ();