Link to home
Start Free TrialLog in
Avatar of MK15
MK15

asked on

php, pass function to method

hi,

i was wondering if it was possible to pass functions in a php class method?

e.g

test.php

function x(){
echo 'here';
}

$func = 'x';
$example = new Example($func());   <------------ is this possible?
-----------------------

class example{

public function __construct($function){
 if(SmartyValidate::is_valid($_POST)) {
           SmartyValidate::disconnect();
        // call the $function here
       } else {

           $smarty->assign($_POST);
           $smarty->display('xyz.tpl'); //set method for display
       }
       }
}}

thank you
ASKER CERTIFIED SOLUTION
Avatar of eriksmtka
eriksmtka
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
additionally, you can look at this function... pretty much the same principle...

PHP Function (call_user_func_array)
Avatar of MK15
MK15

ASKER

thank you so much