0

First of all i feel really stupid of not seeing this problem and not finding an answer on the interweb already. Here is my input class:

<?php
namespace lib\Api;
class Input {
public $value;
public function get($name){
    if(isset($_POST[$name])){
         return $_POST[$name];
    }else if(isset($_GET[$name])){
         return $_GET[$name];
    }
    return null;

}
public function equals($argument){
    $this->getValue() == $argument ? true : false;
}
//etc
}
?> 

Then if i put a invallid $_GET[$name] in there, it is giving the error: Undefined index

Hoping someone can help.

Nytrix
  • 1,139
  • 11
  • 23
  • `!empty()` or `array_key_exists($name, $_POST)` http://php.net/manual/pt_BR/function.array-key-exists.php – B.J. Jul 15 '15 at 16:32

2 Answers2

1

Thank you for the help, but after 3 hours of research. I just uploaded everything again and it worked, very weird.

Nytrix
  • 1,139
  • 11
  • 23
0

Try using either GET_[] or POST_[] for all of them you may have caused some confusion by mixing it up

also how are you sending the data (again GET or POST) and match it with what you use in this function. Hopefully this is of some help :-)

ben jay hutton
  • 402
  • 5
  • 15