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! 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. 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"); ?> 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); ?> 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! 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! 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
Archived
This topic is now archived and is closed to further replies.