This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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