Created
August 25, 2018 20:50
-
-
Save adrian-enspired/1f5fde8dd9e4668d5f7f5aac6d809f7b to your computer and use it in GitHub Desktop.
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