Skip to content

Instantly share code, notes, and snippets.

@adrian-enspired
Created August 25, 2018 20:50
Embed
What would you like to do?
<?php
class Wrong {
public function getX() {
return $_GET['x'] ?? 'default x';
}
}
class Right {
public function __construct(array $params) {
$this->params = $params;
}
public function getX() {
return $this->params['x'] ?? 'default x';
}
}
$wrong = new Wrong();
echo $wrong->getX();
$right = new Right($_GET);
echo $right->getX();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment