Created
October 6, 2011 15:20
-
-
Save JeffreyWay/1267664 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 | |
$someVar = 'some value'; | |
add_action('admin_init', function() { | |
# I want access to $someVar in here, and don't want it to be a global. | |
# Is there a way to pass $someVar into the callback as a local variable? | |
}); |
Okay - use did it. Thanks @rcky! The other two options didn't work for me.
$someVar = 'some value';
add_action('admin_init', function() use($someVar) {
echo $someVar;
});
Just a note here. This syntax will only work in php 5.3+
Yep.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$someVar = 'some value';
add_action('admin_init', function() use($someVar) {
$something = $someVar;
});