You are here

protected function Post::get_variable in Anti Spam by CleanTalk 9.1.x

Same name and namespace in other branches
  1. 8.4 src/lib/Cleantalk/Common/Variables/Post.php \Cleantalk\Common\Variables\Post::get_variable()

* Gets given $_POST variable and save it to memory *

Parameters

$name: * * @return mixed|string

Overrides SuperGlobalVariables::get_variable

File

src/lib/Cleantalk/Common/Variables/Post.php, line 22

Class

Post
Class Post Safety handler for $_POST

Namespace

Cleantalk\Common\Variables

Code

protected function get_variable($name) {

  // Return from memory. From $this->variables
  if (isset(static::$instance->variables[$name])) {
    return static::$instance->variables[$name];
  }
  if (function_exists('filter_input')) {
    $value = filter_input(INPUT_POST, $name);
  }
  if (empty($value)) {
    $value = isset($_POST[$name]) ? $_POST[$name] : '';
  }

  // Remember for thurther calls
  static::getInstance()
    ->remember_variable($name, $value);
  return $value;
}