Last Updated: February 25, 2016
·
409
· gongo

MercifulPolluter (Emulate register_globals on PHP 5.4 or higher)

gongo/merciful-polluter - Packagist

What's this?

MercifulPolluter emulate register_globals and magicquotesgpc that has been removed since PHP 5.4.

Usage

<?php
/**
 * example.com/?foo=3&bar=12
 */

(new Gongo\MercifulPolluter\Requst)->pollute();

global $foo, $bar;
var_dump($foo, $bar);

/**
 * int(3)
 * int(12)
 */

If use the session, call Gongo\MercifulPolluter\Session::pollute() after session_start():

session_start();

/**
 * $_SESSION['user_id'] = 'gongo'
 */

(new Gongo\MercifulPolluter\Session)->pollute();

var_dump($user_id); // string(5) "gongo"

// Reference global variables to session.
$user_id = 'taro';
var_dump($_SESSION['user_id']);

// string(4) "taro"

More informations

See GitHub gongo/merciful-polluter