[英]Hash # is not passing as route parameter in Slim Framework API
I am trying to pass 'Hello world # world' as route parameter, but getting only 'Hello world' as args value as output. 我试图将“ Hello world#world”作为路由参数传递,但仅将“ Hello world”作为args值作为输出。 Rest of data getting truncated.
其余数据将被截断。
$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’
}
});
The #
is a special character in the url spec, you can't use it as input unless encoded. #
是网址规范中的特殊字符,除非经过编码,否则不能将其用作输入。
From php use: urlencode()
and urldecode()
从php使用:
urlencode()
和urldecode()
From js use something like: encodeURIComponent()
在js中,使用类似以下内容的方法:
encodeURIComponent()
That way you'll get %23
instead of #
, which will get stripped. 这样,您将获得
%23
而不是#
,它将被剥离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.