これは動作しません
$check["pattern"] = "/correct/";
$callback = "function ($m) { return ucfirst($m[0]);}";
echo preg_replace_callback($check["pattern"],$callback,"correct" );
output: correct
これは機能します
$check["pattern"] = "/correct/";
echo preg_replace_callback($check["pattern"],function ($m) { return ucfirst($m[0]);},"correct" );
output: Correct
var 内に格納された関数を使用する理由とその方法を教えてください。:)