Last active
December 11, 2015 05:39
-
-
Save maeharin/4554124 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// ワンソース | |
function event() { | |
$args = func_get_args(); | |
$name = array_shift($args); | |
$callable = array_pop($args); | |
$is_call = $callable(); | |
if($is_call) {echo $name;} | |
} | |
$weather = 'sunny'; | |
//$weather = 'rain'; | |
event('今日は晴れています', function() use ($weather) { | |
return $weather === 'sunny'; | |
}); | |
event('今日は雨です', function() use ($weather) { | |
return $weather === 'rain'; | |
}); |
This file contains hidden or 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 | |
function event() { | |
$args = func_get_args(); | |
$name = array_shift($args); | |
$callable = array_pop($args); | |
$is_call = $callable(); | |
if($is_call) {echo $name;} | |
} | |
require 'two_source02.php'; |
This file contains hidden or 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 | |
$weather = 'sunny'; | |
//$weather = 'rain'; | |
event('今日は晴れています', function() use ($weather) { | |
return $weather === 'sunny'; | |
}); | |
event('今日は雨です', function() use ($weather) { | |
return $weather === 'rain'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment