Created
March 31, 2019 06:48
-
-
Save yehchge/89e849783810f76b29c3c8739e37f397 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 | |
/** | |
* @desc decorator | |
*/ | |
function save_db($str){ | |
$wrap_func = function() use ($str) { | |
echo "run wrap_func".PHP_EOL; | |
echo "string = $str".PHP_EOL; | |
}; | |
db_trans($wrap_func); | |
} | |
function save_table($str){ | |
$wrap_func = function() use ($str) { | |
echo "run wrap".PHP_EOL; | |
echo $str.PHP_EOL; | |
}; | |
db_trans($wrap_func); | |
} | |
function db_trans($method){ | |
try{ | |
echo "run db_trans".PHP_EOL; | |
$method(); | |
}catch(Exception $e){ | |
echo $e->getMessage(); | |
} | |
} | |
$str = "John,Mary,David"; | |
save_db($str); | |
save_table($str); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment