Created
January 18, 2018 20:39
-
-
Save f3ath/fb47834ec3a0fbc437a252facc876fe2 to your computer and use it in GitHub Desktop.
Local scope in included files
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 | |
$foo = require __DIR__ . '/foo.php'; | |
var_dump($foo); | |
var_dump(isset($innerVar)); |
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 | |
return (function() { | |
$innerVar = 'This var is invisible'; | |
return 'This is what gets returned'; | |
})(); |
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
[f3ath@proton playground]$ php bar.php | |
/home/f3ath/project/playground/bar.php:3: | |
string(26) "This is what gets returned" | |
/home/f3ath/project/playground/bar.php:4: | |
bool(false) | |
[f3ath@proton playground]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment