Specify a variable name for a function call

Hi, I need to specify a variable name for a function call (imageapi) and then execute the line.

//For example this is my working code:
require($Path.’/lib/imageapi.php’);
new imageapi($ACCESS_TOKEN);

//I want to replace the above lines with:
require($Path.’/lib/imageapi.php’);
$provider = ‘imageapi’;
new $provider($ACCESS_TOKEN);

Your code looks like a class instantiation rather than a function call. Can you be clearer in what you need?

As in the code above I need to be able to place imageapi with a variable and then specify the Variable in this line … new imageapi($ACCESS_TOKEN);

You would have to get that information from the website that is providing the API. That is if I am understanding what you are saying? Even getting how to set it up would be better getting that info from their website as they probably tell you how to use their API.

This has nothing to do with the website. Its generic. Please allow someone else to answer the question if youve unsure

Ok. The second piece of code you’ve written works just fine for me. Are you seeing an error?

Thanks @skawid . Yes its fine. In my initial code (which is a lot larger than the current) I was referencing $provider in a function, but I forgot to pass $provider to the function. My bad.

Sponsor our Newsletter | Privacy Policy | Terms of Service