第二天学PHP,把IDC改成了HBuilder,看样子比IDEA更加的专注Web编程了.
自我总结发现的方法
在Controller中,定义的xxx.php必须和PHP中的class相同(最起码得有一个),不过里面的function名称就不用相同啦
那么根据ThinkPHP中的文档:
http://serverName/index.php/模块/控制器/操作
对于这个function abc的访问应该为
http://localhost/index.php/xxx/xxx/abc/
同时,URL支持对function传参
格式如下
http://localhost/index.php/xxx/xxx/abc/传入变量名称/传入变量值
比如在index.php 中如下:
<?php
namespace app\index\Controller;
class index
{
public function index()
{
echo "this is index";
}
public function getname($name)
{
echo "this is the ".$name." you put in";
}
}
?>
则访问方法getname需要输入
http://localhost/tp5/public/index.php/index/index/getname/name/123
结果如下
多参数传入
http://localhost/tp5/public/index.php/index/index/getname?name=123&age=14