thinkphp学习03-url访问模式
  • 多应用:http://serverName/index.php/应用/控制器/操作/参数/值…;
  • 单应用:http://serverName/index.php/控制器/操作/参数/值…;

http://localhost:8506/index.php
在这里插入图片描述
Contoller下新建Test.php

<?php
namespace app\controller;class Test{}

访问http://localhost:8506/index.php/test
在这里插入图片描述
需要一个默认的index方法

<?php
namespace app\controller;class Test{public function index(){return "Test";}
}

在这里插入图片描述
新建hello方法

public function hello(){return "Hello ";}

访问http://localhost:8506/index.php/test/hello
在这里插入图片描述
修改hello方法

public function hello($value = '')
{return "Hello " . $value;
}

在这里插入图片描述
其中index.php可以忽略,只要设置 URL 重写即可,比如apache、nginx还有iis开启方式不同但是原理一样

URL 兼容模式

如果上面那种形式的 URL 不支持的话,可以使用兼容模式的方式来访问:
http://localhost:8506/index.php?s=test/hello/value/wjl
在这里插入图片描述