thinkphp学习03-url访问模式

  • 多应用:http://serverName/index.php/应用/控制器/操作/参数/值…;
  • 单应用:http://serverName/index.php/控制器/操作/参数/值…;

http://localhost:8506/index.php
thinkphp学习03-url访问模式_第1张图片
Contoller下新建Test.php


namespace app\controller;

class Test{
    
}

访问http://localhost:8506/index.php/test
thinkphp学习03-url访问模式_第2张图片
需要一个默认的index方法


namespace app\controller;

class Test{
    public function index(){
        return "Test";
    }
}

thinkphp学习03-url访问模式_第3张图片
新建hello方法

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

访问http://localhost:8506/index.php/test/hello
thinkphp学习03-url访问模式_第4张图片
修改hello方法

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

thinkphp学习03-url访问模式_第5张图片
其中index.php可以忽略,只要设置 URL 重写即可,比如apache、nginx还有iis开启方式不同但是原理一样

URL 兼容模式

如果上面那种形式的 URL 不支持的话,可以使用兼容模式的方式来访问:
http://localhost:8506/index.php?s=test/hello/value/wjl
thinkphp学习03-url访问模式_第6张图片

你可能感兴趣的:(php,学习,android)