Question : PHP:  use variable in function name?

Hi All,

Is it possible to use a variable in a function name?


i.e.

$img = 'myimage.png';
$filetype = 'png';

$image = 'imagecreatefrom' . $filetype($img);  // should be $image = imagecreatefrompng($filename);



Answer : PHP:  use variable in function name?

Try like below:

$$ should be used here:

$image = 'imagecreatefrom' . $$filetype($img);  // should be $image = imagecreatefrompng($filename);

Hope this helps
Addy
Random Solutions  
 
programming4us programming4us