我想要的是twitter或facebook的url类型。比如我写twitter。com/Username它会直接进入用户的个人资料
无脂框架路由中的是这样分配的,它的工作
$f3->route('GET /about',function($f3)
{
echo 'Donations go to a local charity... us!';
});
然后传递url,如localhost/site/About到浏览器地址栏函数被调用但如果我想动态调用它并写入
$f3->route('GET /@pageName',function($f3)
{
echo 'Donations go to a local charity... us!';
});
然后传递url,如localhost/site/Nisarg它显示了一个404错误,除了
什么也没调用$f3->route('GET /@pagename/*',function($f3)
{
echo 'Donations go to a local charity... us!';
});
然后传递两个/像localhost/site/Nisarg/Desai它被调用知道发生了什么吗?
如果有多个自定义变量的版本呢?
$f3->route('GET /@pageName',function($f3)
{
$this->do($f3);
});
$f3->route('GET /@pageName/@var1',function($f3)
{
$this->do($f3);
});
$f3->route('GET /@pageName/@var1/@var2',function($f3)
{
$this->do($f3);
});
$f3->route('GET /@pageName/@var1/@var2/@var3',function($f3)
{
$this->do($f3);
});
$f3->route('GET /@pageName/@var1/@var2/@var3/@var4',function($f3)
{
$this->do($f3);
});
然后,do函数会对所有函数执行相同的操作,但会考虑valn是否定义。
我在其他语言中见过这种做法。我不确定f3是否已经内置了更好的方法。
根据文档,似乎您可以使用/@var
或 /*
。可能不支持这两种情况。