Restrict people by using PHP GET Variable
get, php
Solution
In php.ini, remove the `G` and `P` characters from the `variables_order` option.
Alternatively, if you want them to hate you forever, you could copy the contents of the superglobal, then set it to an instance of a class that throws an exception whenever you try to interact with it:
class supaglobal implements arrayaccess
{
public function _construct(){}
function offsetExists($offset) {
throw new Exception("Don't use GET, bro");
}
function offsetSet($property, $value){
throw new Exception("Don't use GET, bro");
}
function offsetUnset($property) {
throw new Exception("Don't use GET, bro");
}
function offsetGet($property){
throw new Exception("Don't use GET, bro");
}
}
$approvedget = $_GET;
$_GET = new supaglobal();
$abcd = $_GET["abcd"]; // throws exception
$abcd = $approvedget["abcd"]; // A - OK
Problem
In one of the interview question i get below question "How you can restrict your developers in your custom build framework to use `$_GET` variable." We have our own custom build framework but in our framework we can not restrict people to use `$_GET` or `$_POST` in place of `$this->request->get` or `$this->request->post`. We have method for accessing this variable but people most of the time uses `$_GET` or `$_POST` instead of our methods. Can you please give me answer for that? Thanks