【发布时间】:2011-08-02 09:58:31
【问题描述】:
我希望我的班级中有一个函数来执行一项简单的任务,例如:
function hello($name)
{
return 'hello '.$name;
}
即不一定是静态的(尽管我想它可能是),但与对象无关(不需要引用 $this)。
我是否使用静态函数?即。
static function hello($name){return 'hello '.$name;}
并使用$string = ClassName::hello('Alex'); 调用它
或者有更好的方法吗?
谢谢!
【问题讨论】: