Inspekt\SuperglobalsCage::factory PHP Method

factory() public static method

..
public static factory ( string $config_file = null, boolean $strict = true ) : SuperglobalsCage
$config_file string
$strict boolean
return SuperglobalsCage
    public static function factory($config_file = null, $strict = true)
    {
        $sc = new SuperglobalsCage();
        $sc->makeCages($config_file, $strict);
        // eliminate the $_REQUEST superglobal
        if ($strict) {
            $_REQUEST = null;
        }
        return $sc;
    }

Usage Example

Beispiel #1
0
require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\SuperglobalsCage;
// for the sake of this example, plug-in some values
$_POST['userid'] = '--12<strong>34</strong>';
$_POST['username'] = '******';
?>



    <h2>contents of $_POST</h2>
<?php 
echo "<pre>";
var_dump($_POST);
echo "</pre>";
// create a supercage and pass it a config file path
$sc = SuperglobalsCage::factory('config.ini');
?>


    <h2>config file contents</h2>
<?php 
echo "<pre>";
echo print_r(file_get_contents('config.ini'), true);
echo "</pre>";
?>


    <h2>echo $sc->post->getRaw('userid')</h2>
<?php 
// displays "1234"
echo "<pre>";