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.

Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
user324107
  • 120
  • 2
  • 7
  • 1
    possible duplicate of [How to call PHP function from string stored in a Variable](http://stackoverflow.com/questions/1005857/how-to-call-php-function-from-string-stored-in-a-variable) – Michael Mrozek May 20 '10 at 16:04

2 Answers2

5
$functionname($param);
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
-1

Correction, ok I thought this would work:

$$functionname($param);

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

JasonMichael
  • 2,463
  • 4
  • 26
  • 25
  • $$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()` – Michael Mrozek May 20 '10 at 19:37