2

I need to call a PHP standard function from a string

Example:

$param = "parameter";
$functionname = "createimagefromjpg";
//call the function (with a parameter)

Anyone has an idea how I can do this? It can't be done with call_user_func() because it is a standard function.

1

2 Answers 2

5
$functionname($param);
Sign up to request clarification or add additional context in comments.

Comments

-1

Correction, ok I thought this would work:

$$functionname($param);

but it does not.... the example with one dollar sign works for functions. Nice.

1 Comment

$$name is to find a variable whose name is stored in name, so if you had $foo = "bar"; $bar = "baz"; and you wanted to call baz(), you could do $bar() or $$foo()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.