Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just pass $_GET to your function. inside your function, you can look for the param you want. Or create a second function</p> <pre><code>function getFunctionCall($getParams) { $function = $getParams['function']; returnArray['functionName'] = $function; $getArraySize = count($getParams); for(i = 1; $i &lt; $getArraySize; $i++) { $param = $getParams['param'. $i]; // do any cleaning you need on $param i ; $param = urldecode($param); returnArray['params']['param'.$i] = $param; } return $returnArray; } </code></pre> <p>Now you have a return array and you can do something like this:</p> <pre><code>$mystuff = getFunctionCall($_GET); $functionString = $mystuff['functionName'] . '("' . implode($mystuff[params], '","') . '")"; $myResult = eval($functionString); </code></pre> <p>However, be very careful doing this stuff... functionName could be any old thing under the sun including fopen's, fwrites, etc... It might be a good idea to create an "approved functions" list and check function name against that before allowing it to be called. Also, the way I put the parms in there as strings in the eval is pretty dangerous. You could get string escaping in the passed params. Probably better to do a for loop and have it eval the variable names instead of the variable contents as strings.</p> <p>Finally, if you actually know the number of arguments to your function, it ouwld be much safer to just use </p> <pre><code>$results = $mystuff['functionName']($mystuff[params][param1]); </code></pre> <p>and so on.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload