+ -
当前位置:首页 → 问答吧 → 怎么自定义方法

怎么自定义方法

时间:2011-06-29

来源:互联网

我想添加一个自定义方法如:

function Hello(){
    echo "Hello World!";
}

请问这个添加在什么地方,还有在IndexAction.class.php里如何调用?

作者: Zhouhi   发布时间: 2011-06-29

建议你先把手册看一遍。   ThinkPHP的 url中会指定你要访问的控制器和控制器的方法, 如 index.php/Index/hello  表示 访问 IndexAction控制器的,  hello方法, 所以, 你把hello 写成 IndexAction 的方法就可以用, 访问地址为index.php/Index/hello  就行。 hello方法, 建议小写。

作者: luofei614   发布时间: 2011-06-29