0

I have a problem with Undefined index: action at Line 23. I am not sure how to solve this. Is it by adding single quotes to $'n'. Seeking for assistance. Thank you.

<?php

class get
{
    private $properties = array();

    public function __construct($db)
    {
        foreach ($_GET as $k => $v)
        {
            $v = $db->clean($v);
            $this->$k = $v;
        }
    }

    public function __set($n, $v)
    {
        $this->properties[$n] = $v;
    }

    public function __get($n)
    {
        return $this->properties[$n]; //this is Line 23
    }

    public function __isset($n)
    {
        return isset($this->properties[$n]);
    }

    public function __unset($n)
    {
        unset($this->properties[$n]);
    }
}

?>
user2192094
  • 337
  • 2
  • 6
  • 15
  • Are you sure that you are passing `action` element using `$_GET` (do you have action=... in your url?, is your webserver not removing it?)? The mentioned line expects `action` to be previously set, it is being set based on key => values passed using `$_GET` global variable. Try var_dumping $_GET in the constructor (or saving it to a file) to debug what values you are getting. – Bartosz Pachołek Jan 03 '20 at 06:01
  • Thanks Bartosz Pacholek for your comment, I don't understand what you mean. – user2192094 Jan 03 '20 at 06:18

0 Answers0