In PHP how can I use the urldecode() inside a class. I have the following class
class exam
{
function __constract()
{
$this->get = $_GET;
//decode the url
array_walk_recursive($this->get, array($this, 'urldecode'));
}
}
because it showing the error
Warning: array_walk_recursive() expects parameter 2 to be a valid callback, class ‘exam’ does not have a method ‘urldecode’ on line 7
Advertisement
Answer
You are passing the current object $this and the method name urldecode so it’s looking for $this->urldecode(). Just pass in the name of the built-in function:
array_walk_recursive($this->get, 'urldecode');
However $_GET variables are already decoded. From urldecode():
Warning The superglobals
$_GETand$_REQUESTare already decoded. Usingurldecode()on an element in$_GETor$_REQUESTcould have unexpected and dangerous results.