Inspekt\Inspekt::makeGetCage PHP Method

makeGetCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeGetCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage
    public static function makeGetCage($config_file = null, $strict = true)
    {
        /**
         * @staticvar $_instance
         */
        static $_instance;
        if (!isset($_instance)) {
            $_instance = Cage::factory($_GET, $config_file, '_GET', $strict);
        }
        $GLOBALS['HTTP_GET_VARS'] = null;
        return $_instance;
    }

Usage Example

Beispiel #1
0
<?php

/**
 * Demonstration of:
 * - use of static filter methods on arrays
 * - creating a cage on an arbitrary array
 * - Accessing cage param via array syntax
 */
require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$_GET['locale'] = "en_US";
$_GET['new'] = 1;
$_GET['time'] = 1246233204.5486;
$_GET['id'] = 7444632820;
$_GET['key'] = "2.Hhun0mQ4KF1BfJ_WfeBB3Q__.86400.1246320000-714446282";
$_GET['ss'] = "un4SUm022i5sZ5iIZeNYWQ__";
$_GET['somestuff'] = "i, would, like, some, milk, and__cookies--please!";
$getCage = Inspekt::makeGetCage();
echo "\n<pre>All the cage params:\n\n";
foreach ($getCage as $key => $value) {
    var_dump($key);
    var_dump($value);
    var_dump($getCage->getAlpha($key));
    echo "\n";
}
echo 'Accessing cage param via array syntax "$getCage[\'locale\']" :: ' . Inspekt::getAlnum($getCage['locale']);
echo "\n</pre>\n";
All Usage Examples Of Inspekt\Inspekt::makeGetCage