call_user_func cannot work in Scriptcase but works out of Scriptcase

Hi, guys:
There’s a important question for me and ask for help.

In my Scriptcase project, a form applicaton, in it's OnLoad event, I write code like this:

function increment($var)
{
echo $var . “DDDDD”;
}

$a = 33;
call_user_func(‘increment’, $a);

And it gets error, below:
call_user_func() expects parameter 1 to be a valid callback, function 'increment' not found or invalid function name

And just the PHP code, I save to a single php file named 1.php, it is:

<?php
function increment($var)
{
echo $var . “DDDDD”;
}

$a = 33;
call_user_func(‘increment’, $a);
?>

And I run it, like: http://127.0.0.1:88/scriptcase/1.php (which was exactly the Scriptcase runtime), and it runs perfectly.

How’s that going? Could you help me for this?

Thank you very much.

It was fixed.

Please, investigate and/or ask before to post on Bugs forums. Because this is not a bug, but using incorrectly SC.

Moving.

and the fix was…to use $this->increment ? :slight_smile:

No.
The fix is: call_user_func(increment(), $a);

jsb

I should explain here.

Not $this->increment, because the function name is unknown(I put the function name into the database), because there’s a class for Scriptcase-created form, so we should call like this: call_user_func(array(get_class($this), $myfunc)