CodeIgniter PHP Framework - Need to get query string

前端 未结 12 1494
挽巷
挽巷 2020-11-27 04:07

I\'m creating an e-commerce site using CodeIgniter.

How should I get the query string?

I am using a Saferpay payment gateway. The gateway response will be li

12条回答
  •  执笔经年
    2020-11-27 04:46

    Here's a full working example of how to allow querystrings in Codeignitor, like on JROX platform. Simply add this to your config.php file located at:

    /system/application/config/config.php 
    

    And then you can simply get the querystrings like normal using $_GET or the class below

    $yo = $this->input->get('some_querystring', TRUE);
    $yo = $_GET['some_querystring'];
    

    Here's the code to make it all work:

    /*
    |--------------------------------------------------------------------------
    | Enable Full Query Strings (allow querstrings) USE ALL CODES BELOW
    |--------------------------------------------------------------------------*/
    
    /*
    |----------------------------------------------------------------------
    | URI PROTOCOL
    |----------------------------------------------------------------------
    |
    | This item determines which server global should 
    | be used to retrieve the URI string.  The default 
    | setting of 'AUTO' works for most servers.
    | If your links do not seem to work, try one of 
    | the other delicious flavors:
    |
    | 'AUTO'              Default - auto detects
    | 'PATH_INFO'         Uses the PATH_INFO
    | 'QUERY_STRING'      Uses the QUERY_STRING
    | 'REQUEST_URI'   Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
    |
    */
    if (empty($_SERVER['PATH_INFO'])) {
        $pathInfo = $_SERVER['REQUEST_URI'];
        $index = strpos($pathInfo, '?');
        if ($index !== false) {
            $pathInfo = substr($pathInfo, 0, $index);
        }
        $_SERVER['PATH_INFO'] = $pathInfo;
    }
    
    $config['uri_protocol'] = 'PATH_INFO'; // allow all characters 
    
    $config['permitted_uri_chars'] = ''; // allow all characters 
    
    $config['enable_query_strings'] = TRUE; // allow all characters 
    
    parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
    

    Enjoy :-)

提交回复
热议问题