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_vali d($_POST)) {
SmartyValidate::disconnect ();
// call the $function here
} else {
$smarty->assign($_POST);
$smarty->display('xyz.tpl' ); //set method for display
}
}
}}
thank you
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_vali
SmartyValidate::disconnect
// call the $function here
} else {
$smarty->assign($_POST);
$smarty->display('xyz.tpl'
}
}
}}
thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you so much
PHP Function (call_user_func_array)