Hash # 没有作为 Slim Framework 中的路由参数传递 API
Hash # is not passing as route parameter in Slim Framework API
我正在尝试将 'Hello world # world' 作为路由参数传递,但仅将 'Hello world' 作为 args 值作为输出。其余数据被截断。
$this->post(’/postText/{data}’, function ($request, $response, $args) {
if($request->isPost()) {
echo $feed = $args[‘data’]; //My input is ’ Hello world #world’. Output is only ‘Hello world’
}
});
#
是 url 规范中的特殊字符,除非经过编码,否则不能将其用作输入。
从 php 使用:urlencode()
和 urldecode()
从 js 使用类似:encodeURIComponent()
这样你会得到 %23
而不是 #
,它会被剥离。
我正在尝试将 'Hello world # world' 作为路由参数传递,但仅将 'Hello world' 作为 args 值作为输出。其余数据被截断。
$this->post(’/postText/{data}’, function ($request, $response, $args) {
if($request->isPost()) {
echo $feed = $args[‘data’]; //My input is ’ Hello world #world’. Output is only ‘Hello world’
}
});
#
是 url 规范中的特殊字符,除非经过编码,否则不能将其用作输入。
从 php 使用:urlencode()
和 urldecode()
从 js 使用类似:encodeURIComponent()
这样你会得到 %23
而不是 #
,它会被剥离。