期间“ 。 "在URL重写模式下,GET请求中没有出现PHP变量 [英] Period " . " doesn't come into PHP variable in GET requests in URL Rewriting mode
问题描述
当我从浏览器URL栏中输入一个值时,该值通过GET请求发送到一个php变量,并按预期方式显示该值,但这里的问题是当我输入的值为句点。在值的末尾,值只显示,但不显示周期。如何解决这个问题?我希望它能够显示期间的值。
以下是我的代码:
if(isset($ _ GET ['value'])){// value来自浏览器的网址栏
$ val = $ _GET ['value'];
echo $ val;
问题更新我忘了提到我正在使用URL重写模式,当我通过URL重写模式获取值时会发生这种情况。但是,当我从包括参数名称(index.php?value =)在内的原始URL获取值时,点显示如预期。
页面名称index.php
if(isset($ _ GET ['value'])){// value from browser URL bar
$ val = $ _GET ['value'];
echo $ val;
}
我的.htaccess文件
RewriteEngine On
RewriteRule ^ index /([a-z0-9 _ /。] +)/?$ /review/index.php ?value = $ 1 [L]
看第一个输出:值的最后一段时间,该值仅显示。但在示例二中:如果我将该句点包含在该值的中间,则该值将随句点显示。为什么会发生这种情况? 输出 ,然后爆炸并获取查询字符串。下面是它的方法。 下面是输出结果中的值。见 When I enter a value from browser URL bar, the value comes to a php variable via GET request and displays the value as expected, but the problem here is when I enter a value with a period . at the end of the value, the value only is displaying but the period isn't displaying. How to fix this issue? I want it to be display the value with the period.
below is my code: Question update
I forgot to mention that I am using URL rewriting mode, and this happens when I get the value via URL rewritten mode. But when i get the value from original URL including the parameter name (index.php?value=) the dot displays as expected. Page name index.php my .htaccess file Look at the first output: in that if i place the period at the end of a value, the value only displays. but in example two: if I include the period in the middle of the value, the value displays with the period. Why is this happening? Outputs
I got a solution for this. Because I am not getting the period at the end of the values, I came up with a solution with PHP's SERVER variable. I am getting the current page full url by $_SERVER['REQUEST_URI'] and then exploding them and getting the query string. Below is the method of it. Below there is the output I am getting the period at the end of the values. See 这篇关于期间“ 。 "在URL重写模式下,GET请求中没有出现PHP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<?php
$ getQueryString = explode ( /,$ _ SERVER [ 'REQUEST_URI']);
echo getQueryString [3];
if (isset($_GET['value'])){ // value comes from the browser URL bar
$val = $_GET['value'];
echo $val;
}
if (isset($_GET['value'])){ // value comes from the browser URL bar
$val = $_GET['value'];
echo $val;
}
RewriteEngine On
RewriteRule ^index/([a-z0-9_/.]+)/?$ /review/index.php?value=$1 [L]
<?php
$getQueryString = explode("/",$_SERVER['REQUEST_URI']);
echo getQueryString[3];