主页
PHP
PHP 回调函数
tryphp_callback_functions3
运行 ❯
×
更改方向
保存代码
更改主题
<!DOCTYPE html> <html> <body> <?php function exclaim($str) { return $str . "! "; } function ask($str) { return $str . "? "; } function printFormatted($str, $format) { echo $format($str); } // Pass "exclaim" and "ask" as callback functions to printFormatted() printFormatted("Hello world", "exclaim"); printFormatted("Hello world", "ask"); ?> </body> </html>
Hello world! Hello world?