当url有变量时,$ _GET为空 [英] $_GET is empty when the url has variables

查看:128
本文介绍了当url有变量时,$ _GET为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于 reg.php?lang = no_NO& passkey = test 的网址,我试图获取密码变量,但它一直显示为空白。



当我尝试 print_r($ _ GET); 时,它会打印 Array() code>?!这是怎么发生的?



这个网站看起来像这样

  <?php 

print_r($ _ GET);

包含('.. \libs\Smarty.class.php');
?>

<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title>激活帐户< / title>

(... html code ..)

$ smarty = new Smarty;

// $ smarty-> force_compile = true;
$ smarty-> debugging = false;
$ smarty-> caching = false;
$ smarty-> cache_lifetime = 120;


// PHP gettext api
define('PROJECT_DIR',realpath('./'));

(... define gettext ...)

$ passkey = $ _ GET ['passkey'];

(...使用密钥...)

$ smarty-> display('templates \site.tpl');

?>


< / body>
< / html>

就是这样。我不明白为什么$ _GET显示空白。这让我发疯了一阵子。

解决方案

当我遇到像这样困扰我的东西时,我的脚本直到基本。在脚本的最上面试试这个:

  var_dump($ _ GET); 
出口;

然后您就可以看到实际上它是否从钩子中获得了变量。如果没有,那么可能会有更深层次的东西......就像PHP真的在Apache上运行一样?如果它起作用,开始添加其他东西,直到它再次停止,你可以开始缩小罪魁祸首。

I have a url that look like this reg.php?lang=no_NO&passkey=testand im trying to get the passkey variable, but it keeps showing up blank.

When I try print_r($_GET); it prints Array ( ) ?! How can this happen?

The site look something like this

    <?php

        print_r($_GET); 

        include('..\libs\Smarty.class.php');
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Activate account</title>

(...html code.. )

$smarty = new Smarty;

//$smarty->force_compile = true;
$smarty->debugging = false;
$smarty->caching = false;
$smarty->cache_lifetime = 120;


// PHP gettext api
define('PROJECT_DIR', realpath('./'));

(... define gettext ... )

$passkey=$_GET['passkey'];

(...work with passkey ...)

$smarty->display('templates\site.tpl');

?>


</body>
</html>

thats it. I can't understand why $_GET shows up blank. It's been driving me crazy for a while now..

解决方案

When I run into something that stumps me like this, I always take my script right down to basics. Try this at the very top of your script:

var_dump($_GET);
exit;

Then you can see if in fact it is getting the vars from the hook. If not, then there may be something deeper... like is PHP really running with Apache? If it works, start adding in other things until it stops again and you can start narrowing down the culprit.

这篇关于当url有变量时,$ _GET为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆