namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
//http://localhost/thinkphp323/index.php
//http://localhost/thinkphp323/index.php/Home/Index/index
public function index(){
echo 'hello,thinkphp!';
}
//下面是一个标准的URL访问格式:
//http://serverName/index.php/模块/控制器/操作
//类似.NET MVC&WebAPI 访问传值方式
//visit: http://localhost/thinkphp323/index.php/home/index/hello/name/baby
//output: hello,baby!
//visit: http://localhost/thinkphp323/index.php/home/index/hello?name=JIm
//output: hello,JIm!
//visit: http://localhost/thinkphp323/index.php/home/index/hello
//output: hello,thinkphp!
//visit: http://localhost/thinkphp323/?s=/home/index/hello/name/JImGreen
//output: hello,JImGreen!
public function hello($name='thinkphp'){
echo 'hello,'.$name.'!';
}
public function test(){
header("Content-type: text/html; charset=utf-8");
echo '这是一个测试方法!';
}
protected function hello2(){
header("Content-type: text/html; charset=utf-8");
echo '只是protected方法!';
}
private function hello3(){
header("Content-type: text/html; charset=utf-8");
echo '这是private方法!';
}
}