Last active
January 19, 2016 21:45
-
-
Save lorenzoferrarajr/ec3ea9404fbd392b9810 to your computer and use it in GitHub Desktop.
Demo showing the danger of using PHP's include statement
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 | |
$variable = 'include'; | |
return $variable; |
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 | |
$includeFunction = function($file) { return include $file; }; | |
$variable = 'original'; | |
$config = include "include.php"; | |
var_dump($variable, $config); // include, include | |
$variable = 'original'; | |
$config = $includeFunction("include.php"); | |
var_dump($variable, $config); // original, include | |
$variable = 'original'; | |
$config = [ | |
'uhm' => include "include.php", | |
]; | |
var_dump($variable, $config); // include, [uhm] => include, | |
$variable = 'original'; | |
$config = [ | |
'uhm' => $includeFunction("include.php"), | |
]; | |
var_dump($variable, $config); // original, [uhm] => include |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment