resago Posted February 5, 2008 Share Posted February 5, 2008 I'm having a brain fart and search has failed me. can someone give a quick example? like: function foo ($funk){ do stuff call function as represented by $funk } foo (phpinfo()); thanks! Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/ Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 Not sure what your question is here. Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/#findComment-459235 Share on other sites More sharing options...
PHP Monkeh Posted February 5, 2008 Share Posted February 5, 2008 Not entirely sure if this is the best way, but this worked for me: <?php function foo($funk) { eval($funk()); } foo("phpinfo"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/#findComment-459239 Share on other sites More sharing options...
Barand Posted February 5, 2008 Share Posted February 5, 2008 try <?php $funk = 'phpinfo'; function foo ($f) { $f(); } foo ($funk); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/#findComment-459244 Share on other sites More sharing options...
PHP Monkeh Posted February 5, 2008 Share Posted February 5, 2008 Trust me to over-complicate things and use eval() Barand makes me feel stupid at times! Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/#findComment-459248 Share on other sites More sharing options...
resago Posted February 5, 2008 Author Share Posted February 5, 2008 try <?php $funk = 'phpinfo'; function foo ($f) { $f(); } foo ($funk); ?> well duh... thanks! Quote Link to comment https://forums.phpfreaks.com/topic/89627-solved-passing-a-function-as-an-argument-of-a-function/#findComment-459266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.