在函数里声明$HTTP_SERVER_VARS为全局变量

解决方案 »

  1.   

    php.ini中修改; You should do your best to write your scripts so that they do not require
    ; register_globals to be on;  Using form variables as globals can easily lead
    ; to possible security problems, if the code is not very well thought of.
    register_globals = On  (●); This directive tells PHP whether to declare the argv&argc variables (that
    ; would contain the GET information).  If you don't use these variables, you
    ; should turn it off for increased performance.
    register_argc_argv = On (●)好象其中一个就可以了!!
      

  2.   

    两个都已经打开了,还是没用
    <?
      global $hosts;
      $hosts=$HTTP_SERVER_VARS["HTTP_HOST"];  function host(){
        $goto="Location:http://$hosts/share/error.php";
        return $goto;
      }
      host();
    ?>
      

  3.   

    function host(){
      global $HTTP_SERVER_VARS;
      $goto="Location:http://$hosts/share/error.php";
      return $goto;
    }
      

  4.   

    上面写错了
    <?
      $hosts=$HTTP_SERVER_VARS["HTTP_HOST"];  function host(){
        global $hosts;
        $goto="Location:http://$hosts/share/error.php";
        return $goto;
      }
      host();
    ?>

    <?
      function host(){
        global $HTTP_SERVER_VARS;
        $hosts=$HTTP_SERVER_VARS["HTTP_HOST"];
        $goto="Location:http://$hosts/share/error.php";
        return $goto;
      }
      host();
    ?>
      

  5.   

    $HTTP_*_VARS[]系列不是自动全局变量.
    用$_*[]系列就好了.
    这里就用$_SERVER[]